简体   繁体   English

使用Microsoft Visual C#2010 Express加载DLL

[英]Loading DLLs with Microsoft Visual C# 2010 Express

I'm using Microsoft C# 2010 Express with the FrameLink Express drivers from Imperx. 我将Microsoft C#2010 Express与Imperx的FrameLink Express驱动程序配合使用。 When I try to load the DLL at runtime, I get an exception: 当我尝试在运行时加载DLL时,出现异常:

Unable to load DLL 'VCECLB.dll': The specified module could not be found. 无法加载DLL'VCECLB.dll':找不到指定的模块。 (Exception from HRESULT:0x8007007E) (来自HRESULT:0x8007007E的异常)

If I try to add the DLL as a reference, I get this message: 如果我尝试将DLL添加为参考,则会收到以下消息:

A reference to 'C:\\\\VCECLB.dll' could not be added. 无法添加对“ C:\\\\ VCECLB.dll”的引用。 Please make sure that the file is accessible, and that it is a valid assembly or COM component. 请确保该文件可访问,并且它是有效的程序集或COM组件。

Two questions: 两个问题:

  1. Is this an Express problem (ie some limitation with Express causing the problem)? 这是Express问题吗(即Express的某些限制导致了问题)? I believe the source for the DLL is written in C++, but I wouldn't think that would matter. 我相信DLL的源代码是用C ++编写的,但我认为这无关紧要。

  2. Is there a different way to reference the DLL and/or add it to the project? 有没有其他方法可以引用DLL和/或将其添加到项目中? Something I'm doing wrong? 我做错了什么?

Finally, I've tried adding both the x86 and x64 versions, debug and release. 最后,我尝试添加x86和x64版本,调试和发布。 Same failure to add as a reference every time. 每次都添加相同的失败作为参考。

That DLL doesn't seem to be .NET (nor COM) code - therefore you cannot load it, nor add a reference to it. 该DLL似乎不是.NET(也不是COM)代码-因此,您无法加载它,也不能添加对它的引用。

Doesn't have anything to do with your Express version - it's just not a .NET "compatible" DLL and thus you can't load or reference it. 与Express版本没有任何关系-它不是.NET“兼容” DLL,因此您无法加载或引用它。

In order to use its functionality, you'll probably have to dive into more "arcane" (and more elaborate and more complicated) methods of calling raw C++ code from .NET - or find a .NET compatible counterpart or version of it. 为了使用它的功能,您可能必须深入研究从.NET调用原始C ++代码的更多“ arcane”(以及更详尽,更复杂的方法),或者找到与.NET兼容的对应版本或版本。

Actually, the answer appears to be in the first line of the message: Unable to load DLL 'VCECLB.dll': The specified module could not be found. 实际上,答案似乎在消息的第一行:无法加载DLL'VCECLB.dll':找不到指定的模块。 (Exception from HRESULT:0x8007007E It says it cannot find the DLL, not that the DLL is not compatible. The DLL should be located with the other DLLs with your program, and you need to add the DLL to the solution. (来自HRESULT:0x8007007E的异常,它表示找不到DLL,不是说该DLL不兼容。该DLL应该与您程序中的其他DLL一起放置,并且您需要将该DLL添加到解决方案中。

If by some chance the DLL is compiled as Native C/C++ (ie, Not .NET style), it can be called from a C/C++ that is a .NET style, but not a C# routine. 如果DLL有机会编译为本机C / C ++(即非.NET样式),则可以从.NET样式的C / C ++而不是C#例程中调用它。

So, if the problem is that the module can be found but not loaded, you need to write a C++ (.NET) routine to call from your C# routine (.NET) to call the C++ (Not .NET). 因此,如果问题是可以找到但未加载该模块,则需要编写一个C ++(.NET)例程以从C#例程(.NET)进行调用以调用C ++(Not .NET)。

All code that talks directly to hardware must do this at some level. 直接与硬件对话的所有代码都必须在某种程度上做到这一点。 Most do this for you using multiple DLLs. 大多数使用多个DLL为您完成此操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在 Microsoft Visual C# 2010 Express 中部署项目? - How to deploy a project in Microsoft Visual C# 2010 Express? 可变着色帮助[Microsoft Visual C#2010 Express] - Variable Coloring Help [Microsoft Visual C# 2010 Express] Microsoft Visual Studio C#2010 Express:可以调试但不能构建 - Microsoft Visual Studio C# 2010 Express: Can debug but not build 我应该使用Microsoft Visual C#2010 Express创建针对.Net 3.5的WPF应用程序吗? - should i use Microsoft Visual C# 2010 Express to create a .Net 3.5 targeted, WPF Application? 如何在Microsoft Visual C#2010 Express中更改Windows窗体应用程序的启动图标 - How to change launching icon of windows form application in microsoft visual c# 2010 express WPF / PrismV4:无法在Microsoft Visual Studio C#2010 Express中加载 - WPF/PrismV4: Can't load in Microsoft Visual Studio C# 2010 Express Microsoft Visual C#2010 Express无法构建我简单的单机游戏应用程序 - Microsoft visual C# 2010 express won't build my simple monogame app 在microsoft visual c#2010 express中运行“开始调试”(F5)时仍然显示已删除的按钮 - Removed button still showing when running the 'Start Debugging' (F5) in microsoft visual c# 2010 express Microsoft Visual C#2008减少加载的dll数 - Microsoft Visual C# 2008 Reducing number of loaded dlls Visual C#2010 Express编译错误 - Visual c# 2010 express compiling error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM