How to load an assembly?

  • Thread starter Thread starter CSharper
  • Start date Start date
C

CSharper

I have a web service which loads loads an assembly on the fly. I ran
into a problem loading. The web service has a config file, it has list
of dll that need to be loaded on demand based on the type of input. I
have the dll at the same location of the executing dll. They are
staged in D drive. Now when I try to load using Assembly.LoadFile(),
it fails requiring absolute path. So I changed the code to use
Assembly.GetCurrentDirectory, it didn't work, Application.executepath
and all the other options available but all the commands points to my
w3pp process rather than the current assembly. How can I get to the
path of executing assembly to load the file?
Thanks.
 
I have a web service which loads loads an assembly on the fly. I ran
into a problem loading. The web service has a config file, it has list
of dll that need to be loaded on demand based on the type of input. I
have the dll at the same location of the executing dll. They are
staged in D drive. Now when I try to load using Assembly.LoadFile(),
it fails requiring absolute path. So I changed the code to use
Assembly.GetCurrentDirectory, it didn't work, Application.executepath
and all the other options available but all the commands points to my
w3pp process rather than the current assembly. How can I get to the
path of executing assembly to load the file?
Thanks.

Hi,

You load the assembly using Assembly.Load , try Assembly.Location to
know where the assembly is located
 
CSharper said:
I have a web service which loads loads an assembly on the fly. I ran
into a problem loading. The web service has a config file, it has list
of dll that need to be loaded on demand based on the type of input. I
have the dll at the same location of the executing dll. They are
staged in D drive. Now when I try to load using Assembly.LoadFile(),
it fails requiring absolute path. So I changed the code to use
Assembly.GetCurrentDirectory, it didn't work, Application.executepath
and all the other options available but all the commands points to my
w3pp process rather than the current assembly. How can I get to the
path of executing assembly to load the file?
Thanks.


Server.MapPath should work.
 
Hi,

You load the assembly using Assembly.Load  , try Assembly.Location to
know where the assembly is located
For some reason Assembly.Location reutns the temporary location where
w3pp loaded the dll from.
 
Back
Top