Hi i am loading an assembly as
Assembly testAssembly = Assembly.LoadFile("abc.dll");
Type t = testAssembly.GetType("abc.dll");
but getting an error "Absolute path information is required" however my dll is located in the same folder
wal has a good point about the GetType
method call, but to answer the question:
string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "abc.dll");
Assembly testAssembly = Assembly.LoadFile(path);
If AppDomain.CurrentDomain
isn't reliable, then a slightly more convoluted way:
string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "abc.dll");
You don't need to call Assembly.LoadFile
if your dll is a .NET dll and in the same folder. You can simply call
Type t = Type.GetType("SomeType");
Are you really trying to get the type 'abc.dll' ? This should be a class name, not an assembly name.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With