Precast .net network boot exception

Hi, I load the assembly as

Assembly testAssembly = Assembly.LoadFile("abc.dll"); Type t = testAssembly.GetType("abc.dll"); 

but getting the error "Absolute path information is required", however my dll is in the same folder

+4
source share
2 answers

wal has a good point in calling the GetType method, but to answer the question:

 string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "abc.dll"); Assembly testAssembly = Assembly.LoadFile(path); 

If AppDomain.CurrentDomain not reliable, then in a slightly more confusing way:

 string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "abc.dll"); 
+7
source

You do not need to call Assembly.LoadFile if your dll is dll.NET and in the same folder. You can just call

 Type t = Type.GetType("SomeType"); 

Are you really trying to get the type "abc.dll"? This should be the name of the class, not the name of the assembly.

+2
source

All Articles