开发者

C# .NET 3.5 Loading assembly from network share

I have t开发者_JAVA百科o load a assembly from a network share but im getting an exception:

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 ..\Common\DLLLoader.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)

Anybody had similar problems and could help me figure this out? Strange this is that the same application works on other computer and loads the assembly from network share just fine.


When an assembly loads from a network share, it runs in the context of an intranet application.

By default, an intranet application doesn't have file IO permiessions.

You have a variety of options, from granting IO permissions to all intranet services (bad), or just trusting the particular assembly/folder you want to load with the minimum required permissions.

A good overview of the tools available is on MSDN at http://msdn.microsoft.com/en-us/library/zdc263t0(v=vs.80).aspx

The scope at which you apply policy can be the machine or enterprise level, enterprise level applies to the whole domain, which sounds like it will be most suitable for your application.

If this error only occurs on a few PCs, its possible they have something different about either their group policies, different machine policies, or the permissions of the user accessing the assembly are different.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜