无法在WPF C#应用程序中加载DLL [英] Unable to load DLL in WPF C# application
问题描述
无法加载DLLVCECLB,我在C#WPF应用程序中运行时遇到以下错误消息(VS2010) dll':找不到指定的模块(来自HRESULT的异常:0x8007007E)
发生此错误的代码是参见hDevEnum):
命名空间Imperx.FLExGrabber
{
public class枚举器:IEnumerator
{
private IntPtr hDevEnum;
VCECLB_EnumData枚举数据;
///默认构造函数
public Enumerator()
{
enumData.cbSize =(UInt32)Marshal.SizeOf(enumData);
//打开枚举器句柄
hDevEnum = NativeFunctions.VCECLB_EnumInit(); < --- ---这里错误讯息!
}
///析构函数
〜枚举器()
{
NativeFunctions.VCECLB_EnumClose(hDevEnum);
}
}
}
从现有的项目,它使用Windows窗体应用程序,它运行完美。现在我需要将此解决方案转移到WPF应用程序中。因此,我使用与同一台VS2010相同的机器(Win7 / 64ibt)。平台目标是X64。
问题:我需要将VCECLB.dll文件添加到我的项目中?我不能在引用下添加它,因此我把它放入文件夹... \bin\x64\Release - 但没有成功。
当我检查VCECLB.dll与依赖性walker我得到以下:
问号是否意味着这些DLL丢失?如果是这样,为什么我可以使用相同的VCECLB.dll运行Windows窗体项目?
有没有人知道我如何解决这个问题?
提前感谢
这种错误有两个常见原因:
- 您所指的DLL不在DLL搜索路径上,或者
- 找到您要引用的DLL ,但是它的依赖关系是无法找到的。
通过将DLL放在与可执行文件相同的目录中解决问题1。通过确保安装所有依赖关系来解决问题2。通常这涉及部署DLL所依赖的MSVC运行时。
I get following error message (VS2010) when running in debug mode my C# WPF appliction:
"Unable to load DLL 'VCECLB.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)"
The code where this error occurs is (see hDevEnum):
namespace Imperx.FLExGrabber
{
public class Enumerator:IEnumerator
{
private IntPtr hDevEnum;
VCECLB_EnumData enumData;
/// Default constructor
public Enumerator()
{
enumData.cbSize = (UInt32)Marshal.SizeOf(enumData);
// Open enumerator handle
hDevEnum = NativeFunctions.VCECLB_EnumInit(); <<--- Error message here!!!
}
/// Destructor
~Enumerator()
{
NativeFunctions.VCECLB_EnumClose(hDevEnum);
}
}
}
From the existing project, which uses a windows form application, it runs perfectly. Now I need to transfer this solution into a WPF-application. Therefore I am using the same machine (Win7/64ibt) with the same VS2010. The platform target is X64.
Question: Where I need to add the VCECLB.dll file into my project? I can not add it under references and therefore I put it into the folder "...\bin\x64\Release" - but no success.
When I check the VCECLB.dll with dependency walker I get following:
Does the question marks means that those dll's are missing? If so, why I can run the windows form project with the same VCECLB.dll?
Does anybody know how I can solve this issue? Thanks in advance
There are two common causes for such an error:
- The DLL that you are referring to is not on the DLL search path, or
- The DLL that you are referring to is found, but its dependencies cannot be found.
Resolve problem 1 by putting the DLL in the same directory as the executable. Resolve problem 2 by making sure that all dependencies are installed. Typically this involves deploying the MSVC runtime that the DLL depends upon.
这篇关于无法在WPF C#应用程序中加载DLL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!