无法使用assembly.loadfrom加载程序集 [英] Not able to load assembly using assembly.loadfrom

查看:323
本文介绍了无法使用assembly.loadfrom加载程序集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

public static IDashboardService CreateDataAccessLayer()
      {
          //string classname = path + ".DashboardFactoryService";
          var assembly = Assembly.LoadFrom("Dashboard.dll");
          return (IDashboardService)(Assembly.Load(path).CreateInstance(classname));
      }





我正在尝试加载程序集Dashboard.dll,这是同一解决方案中的一个项目。 />
但是当我使用Assembly.LoadFrom()时出现以下错误





I am trying to load the assembly Dashboard.dll, which is a project in the same solution.
But when I use Assembly.LoadFrom() I get the following error

An exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll but was not handled in user code

Additional information: Could not load file or assembly 'file:///C:\Program Files (x86)\IIS Express\Dashboard.dll' or one of its dependencies. The system cannot find the file specified.





我尝试了什么:



我尝试在当前项目中添加Dashboard项目的引用。

我也尝试使用





< runtime>

< assemblybinding xmlns =urn:schemas-microsoft-com:asm.v1>

< probing privatepath =bin; bin2>







但不包括work



What I have tried:

I have tried adding the reference of Dashboard project in current project.
I also tried loading it from bin folder using


<runtime>
<assemblybinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatepath="bin;bin2">



but does not work

推荐答案

Assembly.LoadFrom()需要完整路径,例如C:\\folder\\filename.dllAssembly.LoadFrom Method(String)(System.Reflection) [ ^ ]
Assembly.LoadFrom() requires a full path e.g. "C:\\folder\\filename.dll" : Assembly.LoadFrom Method (String) (System.Reflection)[^]


这篇关于无法使用assembly.loadfrom加载程序集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆