c# . net 3.5从网络共享加载程序集



我必须从网络共享加载程序集,但我得到一个异常:

17.08.2011 9:50:50: Exception: TargetInvocationException - "Exception has been thrown by the target of an invocation."
        System.Object _InvokeMethodFast(System.Object, System.Object[], System.SignatureStruct ByRef, System.Reflection.MethodAttributes, System.RuntimeTypeHandle)
           at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
       at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
       at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
       at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
       at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
       at MachineInterface.Common.DLLLoader.ExecuteChipConverter(String dllPath, Hashtable cardData, String customerCode) in ..CommonDLLLoader.cs:line 54
17.08.2011 9:50:50: Exception: SecurityException - "Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed."
        Void Check(System.Object, System.Threading.StackCrawlMark ByRef, Boolean)
           at System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet)
       at System.Security.CodeAccessPermission.Demand()
       at System.Reflection.Assembly.get_Location()
       at CombosHelper.CombosDataFile.GetTemplateByAlias(String Alias)
       at TSPHelper.ChipDataConverter.ConversionProvider.DChipToChipXpressStartMessage(String DChipHexString, String customerCode, String CustomerCardTypeCode, String ArticleCode)
       at ToChipXpressStartMessage(Hashtable cardData, String customerCode)
谁有类似的问题,可以帮我解决这个问题?奇怪的是,同样的应用程序可以在其他计算机上运行,并且可以从网络共享加载程序集。

当程序集从网络共享加载时,它将在内部网应用程序的上下文中运行。

默认情况下,内网应用没有文件IO权限。

您有多种选择,从授予所有内部网服务(坏)的IO权限,或者仅仅信任您想要加载的特定程序集/文件夹所需的最小权限。

可用工具的一个很好的概述是在MSDN http://msdn.microsoft.com/en-us/library/zdc263t0(v=vs.80).aspx

您应用策略的范围可以是机器级或企业级,企业级适用于整个域,这听起来像是最适合您的应用程序。

如果这个错误只发生在一些pc上,可能是他们的组策略不同,不同的机器策略,或者访问程序集的用户权限不同。

最新更新