Hi everyone, sorry about my english. Im having a problem and i don't know how to fix it.

I have a plugin-based application that i'm developing. Every plugin has a reference to a dll that has different static classes with functions. When i run the application with all the dlls (plugins and their references) in the same directory, the application works fine. But the problem comes when i change the application's path, leaving the dlls in other path. When i run the application, the plugin dll thrown an exception saying that the "functions dll" could not be found, but the dll is in the same directory as the plugin :| .

If i don't explain well:
C:\app.exe
C:\plugin.dll
C:\functions.dll
It works fine.

C:\test\app.exe
C:\plugin.dll
C:\functions.dll
It doesn't work.

I don't know where is the problem.
I'll be really grateful for your help.

Thanks
Greetings

Recommended Answers

All 8 Replies

try:
C:\test\app.exe
C:\test\plugin.dll
C:\test\functions.dll

C:\test\app.exe
C:\plugin.dll
C:\functions.dll
It doesn't work.

In the above scenario, have you tried running the app with "C:\" in your PATH environment settings?

It's not clear to me how your app is able to find and load the plugin.dll, but not the other. Could it be that the plugin.dll is registered and windows knows where to find; whereas this is not true for the functions.dll?

You save the path of the dlls. Put it as a constant fields in one of your classes. (e.g. public static string dllPath = "C:\\") and when you start the application, do this: Assembly.LoadFile(dllPath + "functions.dll")

Hi, thanks for your reply, but i think that the problem is not the app.
The app works like this: the plugins, with the "functions dll", are in a path (like "C:\program files\app\plugins\"). The program is in another path, it doesn't matter. The app searchs in the registry for the "plugins path", and dynamically loads the plugin. The load is always ok, but the problem is when i call the "execute" method(it's a public method of the plugin), that has a reference to the "functions dll", throwing an exception saying that the plugin couldn't find the "functions dll", but its in the same directory of the plugin. i don't know why the plugin doesn't "see" the "functions dll".

note: the plugin is a "class proyect library", that i've developed, who has a "reference" to the "functions dll".

Hi, this image could help.

I also tried to register the functions.dll with the gac, but it still not working.

Thanks

Hi, this image could help.

I also tried to register the functions.dll with the gac, but it still not working.

Thanks

It sounds like the plugin is expecting the functions.dll to be in the entry-assembly's path. How is the plugin referencing this dll? I assume you have the build for the plugin too since both the app and the plugin references it? Have you looked into the Assembly.LoadFrom method: http://msdn.microsoft.com/en-us/library/1009fa28.aspx?

Hi everyone. I found the solution!
I used the app.config to add a private path, and its now working!! :)

Thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.