我有这堂课:
public class PlaceLogicEventListener : ILogicEventListener
{
}
我有这段代码试图通过反射创建一个实例:
public ILogicEventListener GetOne(){
Type type = typeof (PlaceLogicEventListener);
return (ILogicEventListener)Activator.CreateInstance(type.Assembly.Location, type.Name);
}
我收到以下异常:
System.TypeInitializationException : The type initializer for 'CrudApp.Tests.Database.DatabaseTestHelper' threw an exception.
----> System.IO.FileLoadException : Could not load file or assembly 'C:\\Users\\xxx\\AppData\\Local\\Temp\\vd2nxkle.z0h\\CrudApp.Tests\\assembly\\dl3\\5a08214b\\fe3c0188_57a7ce01\\CrudApp.BusinessLogic.dll' or one of its dependencies. The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)
我GetOne()
从测试 dll 中调用。的代码PlaceLogicEventListener
和方法GetOne()
都在同一个程序集中CrudApp.BusinessLogic.dll