简体   繁体   English

无法在Assembly.LoadFrom方法中加载程序集

[英]Unable to load assembly in Assembly.LoadFrom method

I am facing a problem while loading a assembly using Assembly.LoadFrom method. 使用Assembly.LoadFrom方法加载程序集时遇到问题。 Following is the code. 以下是代码。

Assembly theAssembly = default(Assembly);
string PathOfAssembly="C:\\Myapplication\\BasicACHTransmitters.dll";
//Load the assembly into memory
theAssembly = Assembly.LoadFrom(PathOfAssembly);

in the last line theAssembly = Assembly.LoadFrom(PathOfAssembly) I am getting following error. 在最后一行theAssembly = Assembly.LoadFrom(PathOfAssembly)我得到以下错误。

Unable to load assembly BasicACHTransmitters at M3.AKAP.frmACHSetUp.LoadClasss.LoadClass(String AssemblyName, String ClassName, String InterfaceRequired) in c:\\Builds\\1\\AccKnowledge\\AK3-QA-LS5-Manual\\Sources\\AccKnowledge\\Code\\Ack3.0-QA\\UI\\M3.AKAP\\frmACHSetUp.cs:line 522. 无法在c:\\ Builds \\ 1 \\ AccKnowledge \\ AK3-QA-LS5-Manual \\ Sources \\ AccKnowledge \\ Code \\ Ack3中的M3.AKAP.frmACHSetUp.LoadClasss.LoadClass(String AssemblyName,String ClassName,String InterfaceRequired)中加载程序集BasicACHTransmitters .0-QA \\ UI \\ M3.AKAP \\ frmACHSetUp.cs:第522行。

I am unable to find the solution of this and I am stuck now. 我找不到解决方案,现在被困住了。 Please help me to resolve this problem. 请帮助我解决此问题。 Any help will appreciated. 任何帮助将不胜感激。

Note: The same code is working successfully on another machine with same assembly. 注意:相同的代码在具有相同程序集的另一台计算机上成功运行。

Try using this link using Reflection method. 尝试使用反射方法使用此链接。 Sample 样品

1.) Try open the file using a reflector tool like just decompile 1.)尝试使用反射器工具(如反编译 )打开文件

I would assume the file isn't a .net assembly 我认为该文件不是.net程序集

2.) If it is a assembly check wether you have the permissions to access the file. 2)如果是程序集检查,则您是否有权访问该文件。 If it is a .net policy prevent access and not a windows permission you can Use Caspol.exe to make the file trustworthy For example: 如果它是.net策略,则禁止访问而不是Windows权限,则可以使用Caspol.exe使文件可信,例如:

caspol -machine -addfulltrust Z:\myNetworkAssembly.dll

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM