URGENT :system reflexion of assenbly question?

  • Thread starter serge calderara
  • Start date
S

serge calderara

Dear all,

I need to create an instance object of a library wit the
following way:

obj = AppDomain.CurrentDomain.CreateInstanceFromAndUnwrap
("Mylib.dll, "PluginApp.PlugIn")

This works fine as long as I place mylib.dll in the same
place as my application EXE file.

If I place that file in a particular folder like \PLUGIN,
I get an error saying it cannot find the file.

How can I make it working in order in search for the file
in \PLUGIN folder ???

thnaks for your help
regards
serge
 
C

calderara serge

Hello,

I have try to use the AppenPrivate path to current domain for assembly
reflexion as follow :

AppDomain.CurrentDomain.AppendPrivatePath(Application.StartupPath +
Global.ENVIRONMENT_PATH.PLUGINS_FILE_PATH)

obj = AppDomain.CurrentDomain.CreateInstanceFromAndUnwrap(item.FileName,
"PluginApp.PlugIn" + item.Name)

Doing this it is still able to load my assembly only if it is present in
my application folder. It does not search in the folder that I specified
in AppendPrivatePath.

What am i doing wrong ?

Thnaks for your reply
serge
 
K

Klaus H. Probst

AppendPrivatePath will work only if the path is relative to the app's root
folder. I don't know if you know that, sorry I didn't mention it. The actual
path has to be in relative form as well.

Or, you could use Assembly.LoadFile(). Have you tried that one?
 
C

calderara serge

Dear sir,

When I check the CurentDomain.BaseDirectory value , it has path :
E:\Runtime which is actually the path where my application is executed.

Then in AppenPrivatePath(PLUGIN_FILE_PATH) , the constant
PLUGIN_FIL_PATH = "Plugins"

So normally the search path should be : E:\Runtime\Plugins

Do I set the correct path for AppenPrivatepath ?
Does the syntax is corect ?

thnaks for your help
serge
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top