Asp.Net C#DllImport问题 [英] Asp.Net C# DllImport problem

查看:104
本文介绍了Asp.Net C#DllImport问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的网站项目中导入DLL文件。我在文件夹C:\DLLDir中有dll文件 my.dll,并且正在使用以下代码:

I want to import DLL file in my web site project. I have dll file "my.dll" in folder C:\DLLDir and I'm using the code :

[DllImport("C:\\DLLDir\\my.dll", EntryPoint = "Out32")]

这正常。但是我想使用相对路径(网站根路径)。我试图将 my.dll放入 bin或根文件夹中,并且正在使用以下代码:

This works ok. But I want to use relative path (web site root path) . I'm trying to put "my.dll" in "bin" or root folder and I'm using the code :

   [DllImport("my.dll", EntryPoint = "Out32")]

但我得到了错误:无法加载DLL'my.dll':找不到指定的模块。 (来自HRESULT的异常:0x8007007E)

but I'm getting the error: Unable to load DLL 'my.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

有什么想法吗?

推荐答案

我认为您可能想先检查以下SO问题(因为它与您的情况有关):

I think you may want to check out the following SO question first (since it's related to your case):

DllImport也无法找到DLL,即使它位于PATH中

按照其他人的建议,检查 PATH 环境变量以确保 C:\DLLDir\ \ 在那儿。您可以在此处了解更多有关如何配置环境变量的信息。

As other people has suggested, check the PATH environment variable to make sure that C:\DLLDir\ is there. You can read more about how to do configure your environment variables here.

查看此 MSDN论坛帖子(似乎是依赖项存在问题)。

Check out this MSDN forum post as well (seems like there was an issue with dependencies).

如果您要导入的COM DLL,然后它可能还需要先在目标计算机上注册(尽管我不确定是否需要这样做)。 在此处了解更多

If it's a COM DLL you're importing then it might also requires to be registered first on a target machine (although I'm not sure if this is needed). Read more here.

这篇关于Asp.Net C#DllImport问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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