- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我在尝试从我的应用程序(用 C# 框架 4.0 编写)中使用非托管代码 dll
时遇到了一些困难。我正在使用 dll
导入如下
[DllImport(@"C:\MGW_SDK.dll", EntryPoint = "fInicializaSDK")]
public static extern int fInicializaSDK();
奇怪的是,当从我的开发环境 (Windows XP) 调用时,它工作得很好,但是当在生产服务器 (Windows7) 上时,它会生成以下异常:
System.DllNotFoundException
: Unable to load DLL' C:\MGW_SDK.dll'
: The specified module could not be found. (Exception from HRESULT: 0x8007007E) atComtpaq.AdminPack.SDKWrapper.fInicializaSDK()
atComtpaq.AdminPack.AdminPaqRepository.InitializeSDK()
inC:\Work\AgroIn\AdminPaqRepository.cs
:line 30
我已经运行了 Dependency Walker ,它显示以下依赖项存在冲突:C:\windows\system32\SHLWAPI.DLL
我已经尝试将那个 dll
复制到我的部署目录
MGW_SDK.dll
位于c:\
(如路径所示)
我已经安装了 C 运行时库
我还注意到一些有趣的东西:在异常情况下,开发路径显示为 C:\Work\AgroIn\AdminPaqRepository.cs:line 30
这里还有什么问题?
我仅使用 MGW_SDK.dll
中使用的 extern
/dllimport
方法之一构建了一个小型控制台应用程序,并使用没问题(没有任何 DllNotFoundException
),所以这似乎与我正在构建的应用程序(WCF 服务)有关。此服务托管在 WAS 上,但我仍然找不到问题。
最佳答案
嗯,这是一个非常棘手的问题。它与 dll 依赖关系无关,也与 dll 位置无关。这与我如何调用 DllImport
无关。这是权限问题。
基本上这个问题是通过删除然后重新添加对dll所在文件夹的执行权限来解决的。参见 this article (回溯机)。
Solution
Oracle 9.2 Client software requires that you give the Authenticated User privilege to the Oracle Home by following these steps:
Log on to Windows as a user with Administrator privileges.
Launch Windows Explorer from the Start Menu and and navigate to the
ORACLE_HOME
folder. This is typically the "Ora92" folder under the "Oracle" folder (i.e.D:\Oracle\Ora92
).Right-click on the ORACLE_HOME folder and choose the "Properties" option from the drop down list. A "Properties" window should appear.
Click on the "Security" tab of the "Properties" window.
Click on "Authenticated Users" item in the "Name" list (on Windows XP the "Name" list is called "Group or user names").
Uncheck the "Read and Execute" box in the "Permissions" list under the "Allow" column (on Windows XP the "Permissions" list is called "Permissions for Authenticated Users").
Re-check the "Read and Execute" box under the "Allow" column (this is the box you just unchecked).
Click the "Advanced" button and in the "Permission Entries" list make sure you see the "Authenticated Users" listed there with:
Permission = Read & Execute
Apply To = This folder, subfolders and filesIf this is NOT the case, edit that line and make sure the "Apply onto" drop-down box is set to "This folder, subfolders and files". This should already be set properly but it is important that you verify this.
Click the "Ok" button until you close out all of the security properties windows. The cursor may present the hour glass for a few seconds as it applies the permissions you just changed to all subfolders and files.
Reboot your computer to assure that these changes have taken effect (IMPORTANT).
Re-execute the application and it should now work.
关于c# - DllImport 生成 System.DllNotFoundException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3818482/
我在某些 Windows 机器上的独立构建中遇到 DLLNotFoundException,其他机器则运行良好。 Dll文件肯定在plugins文件夹中,也将其复制到projectName_Data文
我正在尝试使用 ZeroMQ C# 绑定(bind) ( http://www.zeromq.org/bindings:clr ) 与我在 Unity 中创建的游戏的服务器进行通信(我使用的是 Mac
我正在尝试在我的统一项目中使用一个 Assets ,它有一个 c# script.cs,它在游戏开始时调用并初始化插件。但是当我按下播放按钮时,unity 不断抛出 DllNotFoundExcept
我的 WPF 应用程序运行良好,但当我将它部署为 ClickOnce 应用程序时,它甚至无法启动。但在 Windows 事件查看器中抛出了以下异常: Application: Saito ERC-C.
我正在尝试在 EmguCV 3.1 中运行 LicensePlateRecognition 示例。但我总是收到错误 System.DllNotFoundException 并且消息是“无法加载 cve
我卸载了 Xamarin Studio(因为 xamarin 是免费的)并尝试在 VS 上运行我的应用程序,但收到此错误: System.DllNotFoundException: java-inte
我已经安装了版本1,1,1的Microsoft.Data.Sqlite Nuget包(因为我有Visual Studio 2015并且不支持2.0.0)。在 x86 和 x64 中一切正常,但问题出现
每当我的应用程序尝试使用 DLL 中存在的函数时,我会收到一个 .dll 的 System.DllNotFoundException,它与可执行文件位于同一文件夹中。奇怪的是,它只发生在一个用户的 P
我是 MonoDevelop 工具的新手。请有人帮忙解决这个问题。 当我尝试连接到 MySql DB 时收到此错误(但是我可以通过终端进行连接)。我在 ubundu 14.4 上运行 mono。 Sy
我正在尝试运行从中导入的 Assets https://www.assetstore.unity3d.com/en/#!/content/10693 它在 windows 中运行良好,但我在 Linu
我在我的 Windows 窗体应用程序中集成了 Geckofx45.64 - 在某些 Windows10 发行版上,我在启动后立即收到以下错误: System.DllNotFoundException
当我们在程序中加载 DLL 时出现以下错误并抛出以下错误: Unable to load DLL 'xxx.dll': The specified procedure could not be fou
这是我第一次尝试为 Android/iOS 创建一个库 c++。 我正在使用 Visual Studio 2015 - Xamarin。 首先我创建了一个项目:Visual C++ -> 跨平台 ->
我在尝试从我的应用程序(用 C# 框架 4.0 编写)中使用非托管代码 dll 时遇到了一些困难。我正在使用 dll 导入如下 [DllImport(@"C:\MGW_SDK.dll", EntryP
我正在使用 Monodevelop 并且有一个 C# 主程序调用一个用 C 编写的共享对象文件。解决方案构建成功,但是当我尝试运行它时,我得到上面的 System.DllNotfoundExcepti
所以我使用了一个用于硬件随机数生成器的 SDK,它提供了一个名为 PsyREG.dll 的 dll 用于与其交互,以及一些用于使用 dll 中的方法的 c# 源代码。 它在过去有效,但不知何故它已停止
我能够在我的开发箱上构建和执行我的 Winforms 应用程序,但是当我尝试在另一个干净的箱子(虚拟机)上运行我的应用程序时,我遇到了这个错误。 Application: MyApp.exe Fram
我是 Unix/Linux/Ubuntu 的新手。 我正在将 Mono 与 VB 一起使用,我正在尝试通过 DllImport (CliSiTef32I.dll/libclisitef.so) 使用库
当尝试将单声道应用程序捆绑在 snap 包中时,当应用程序尝试发出简单的 HTTP 请求时,我会收到此异常: System.AggregateException: One or more errors
我使用 ARFoundation 包在 Unity 中构建了一个 ARCore 应用程序。然后我按照以下链接中的说明将 Unity 应用程序嵌入到原生 Android 应用程序中:Embedded U
我是一名优秀的程序员,十分优秀!