无法从C#.NET加载Win32 Native DLL文件 [英] Unable to load Win32 Native DLL file from C#.NET

查看:203
本文介绍了无法从C#.NET加载Win32 Native DLL文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个C#winapp。我从C#应用程序调用一个本机的.dll文件(由C ++自己创建),并且工作正常。



但是当我复制我的应用程序(.exe和。 dll文件)到另一台机器,我得到一个错误,说:



无法加载DLLc:\dllname.dll:指定的模块可以没有找到。 (HRESULT的异常:0x8007007E)



这是C#代码:

  class IsoMessageHelper 
{
public const string ISO8583_DLL =c:\\Hc8583.dll;
[DllImport(ISO8583_DLL,CallingConvention = CallingConvention.Cdecl)]
public static extern bool InitializationRq(...)
}

我应该怎么做?

解决方案

部署时常见的问题。具有本机依赖关系的网络应用程序是本机dll可能在目标机器上本身丢失依赖关系,例如C运行时的正确版本。



使用 Dependency Walker 来分析您的本地DLL,并确定它是否与您已复制的机器缺少依赖关系。


I have a C# winapp. I call a native .dll file (created in C++ by myself) from the C# app, and it works fine.

But when I copy my application (.exe and .dll files) to another machine, I get an error that says:

Unable to load DLL "c:\dllname.dll": The specified module could not be found. (Exception from HRESULT: 0x8007007E)

Here is the C# code:

class IsoMessageHelper
{
    public const string ISO8583_DLL = "c:\\Hc8583.dll";
    [DllImport(ISO8583_DLL, CallingConvention = CallingConvention.Cdecl)]
    public static extern bool InitializationRq(...)
}

What should I do?

解决方案

A common issue when deploying .Net applications that have native dependencies, is that the native dlls may be missing dependencies themselves on the target machines e.g. the correct version of the C runtime.

Use a tool such a Dependency Walker to analyze your native dll and determine if it has a missing dependency on the machine you have copied it too.

这篇关于无法从C#.NET加载Win32 Native DLL文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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