更改路径时找不到DLL [英] dll not found when changing the path

查看:122
本文介绍了更改路径时找不到DLL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,对不起我的英语。我有一个问题,我不知道如何解决它。


我有一个基于插件的应用程序,我正在开发。每个插件都引用了一个带有函数的不同静态类的dll。当我在同一目录中运行所有dll(插件及其引用)的应用程序时,应用程序正常工作。但问题来自于我改变应用程序的路径,将dll留在其他路径中。当我运行应用程序时,插件dll抛出一个异常,说函数dll。无法找到,但dll与插件位于同一目录中:| 。


如果我不能解释清楚:

C:\ app.exe

C:\plugin .dll

C:\ functions.dll

工作正常。


C:\test\app。 exe

C:\plugin.dll

C:\ functions.dll

它不起作用。


我不知道问题出在哪里。

我会非常感谢你的帮助。


谢谢

问候

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

推荐答案

嗯,这取决于加载插件所需的代码。但是,我打赌它只是看着工作目录(即LoadPlugin(plugin.dll)或者其他一些东西。


那是'为什么它没有找到插件...它可能在同一个目录中查找app.exe已经用完了,所以当你改变它时它找不到它们。我打赌如果你动了你的两个插件进入c:\ test文件夹,它会再次运行。


你有几个选项(我能想到的)...


1)将插件保存在与应用程序相同的目录中。只要您将插件与应用程序保持在一起就可以了(尽管您可能希望将它们放在插件文件夹中(即.\plugins\plugin.dll和。\\\\\\\\\\\\\\\\\\ .dll")


2)硬编码你的插件文件夹。而不是通过插件名称加载,完全限定它(即,c:\plugin.dll和c:\ functions.dll)。我不推荐这个,因为它非常严格。您可能希望在其他计算机上部署您的应用程序,用户可能不希望总是在同一文件夹中。


3)允许您的应用程序配置插件文件夹的路径。如果你想从任意位置加载你的插件,这是特别好的。


在这三个中,第三个可能是最好的。解决方案,因为它给你最大的自由;然而,第一个也是完全可以接受的。我自己编写了一个插件系统,实际上我使用了第一个解决方案(虽然我的插件位于工作目录下的子文件夹中),其中涉及相关文件链接。


希望有一个这些可以帮助你,或者至少可以帮助你想出一个更好的方法。祝你好运!
Well, it depends on the code you have to load your plugins. However, I''m betting it''s just looking in the working directory (ie, LoadPlugin("plugin.dll") or some such thing.

That''s why it''s not finding the plugins... it''s likely looking in the same directory app.exe is running out of, so when you change that it won''t find them. I bet if you moved your two plugin dlls into the c:\test folder, it would work again.

You''ve got a couple of options (that I can think of)...

1) Keep your plugins in the same directory as your application. This is fine as long as you keep your plugins with your application (though you may want to put them in a plugins folder (ie, ".\plugins\plugin.dll" and ".\plugins\functions.dll")

2) Hard code your plugins folder. Instead of loading by the plugin name, fully qualify it (ie, "c:\plugin.dll" and "c:\functions.dll"). I wouldn''t recommend this since it''s pretty restrictive. You may want to deploy your app on other computers and users may not want things to always go in the same folder.

3) Allow your app to configure the path to the plugins folder. This is especially good if you want your plugins to be loaded from any arbitrary location.

Of the three, the third is probably the "best" solution as it gives you the most freedom; however, the first is also perfectly acceptable. I''ve written a plugin system myself and I actually used the first solution (though I had my plugins in a subfolder off my working directory) that involved relative file links.

Hopefully one of those helps you, or at least helps you think of a better way of doing it. Good luck!


非常感谢您的回复,但问题不在于应用程序,它在插件中,因为当我把应用程序放在插件目录中时,它运行正常,但是当我把应用程序放在另一个目录中时,它找到了插件,但插件并没有看到函数dll = S.我认为它就像插件使用应用程序启动路径一样。 搜索引用(函数dll),当插件和应用程序在同一目录中时,它工作正常,但当我将应用程序移动到另一个路径时,插件将搜索应用程序中的引用的新路。我不知道会发生什么。
Hi, thanks a lot for your reply, but the problem is not the application, its in the plugin, because when i put the application in the plugin directory, it works fine, but when i put the application in another directory, it founds the plugin, but the plugin doesn''t "see" the functions dll =S. i think its like the plugin uses the application "startup path" to "search for the references"(functions dll), and when the plugin and the application are in the same directory, it works fine, but when i move the application to another path, the plugin searchs for the references in the application''s new path. i don''t have idea what could be.


哦,我看,plugin.dll需要找到function.dll吗?


再次,我真的没有你的代码,但是plugin.dll通过询问目录来查找function.dll吗?如果是这样,那将是问题,因为工作目录是针对app.exe的。你需要指示plugin.dll在找到plugin.dll的同一目录中找到function.dll .App.exe应该可以告诉你它在哪里找到了plugin.dll。

对不起,我们很抱歉。
Oh I see, plugin.dll needs to find function.dll?

Again, I don''t really have your code, but does plugin.dll look for function.dll by just asking for the directory? If so, that would be the problem, since the working directory is for app.exe. You''ll need to direct plugin.dll to look for function.dll in the same directory plugin.dll was found in. App.exe should be able to tell you where it found plugin.dll.

Sorry for the confusion.


这篇关于更改路径时找不到DLL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆