为什么需要将非MFC DLL编译为“在静态库中使用MFC"才能在VB中引用它? [英] Why would a non-MFC DLL need to be compiled to “Use MFC in a Static Library” in order to reference it in VB?

查看:92
本文介绍了为什么需要将非MFC DLL编译为“在静态库中使用MFC"才能在VB中引用它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我什至无法量化这个论坛为我提供的次数解决方案,但我最终遇到了似乎尚未得到解决的问题.  在VB表单中,我已经使用标准格式(例如,公共声明函数FunctionName Lib< DLLName.dll”()作为ReturnType)从DLL声明了我要使用的函数. =">  一切在开发计算机上都可以正常运行,但是任何其他计算机都无法加载DLL,除非该DLL编译时带有在静态库中使用MFC"选项.与使用标准Windows库"默认值.  所有机器都是最新的.Net 3.5,这是我最初认为的原因.
此处是链接:
https://oncourse.iu. edu/access/content/user/angleton/Filemanager_Public_Files/DLL%20Problem/DLL%20Problem.zip

Hello, I can’t even quantify the number of times this forum has provided me with solutions, but I’ve finally ran into something that doesn’t appear to have already been answered.  I’ve got a multiple-project solution, developed entirely in VS 2008, that references a C++ DLL in VB.  The C++ DLL was created as a Win32 Project whose only non-default settings were “Application type=DLL” and “Export symbols” selected.  I added a module file with the function exports to the DLL project in order to reference it in VB.  In the VB form, I’ve declared the function I want to make use of from the DLL using the standard format (e.g. Public Declare Function FunctionName Lib “DLLName.dll” () As ReturnType).  Everything works fine on the development machine, but any other machine is unable to load the DLL, UNLESS the DLL is compiled with the option to “Use MFC in a Static Library” as opposed to the “Use Standard Windows Libraries” default.  The DLL does not use MFC, so I don’t understand why this would be necessary; indeed I actually discovered it on accident because it certainly wasn’t the first thing I thought was causing the problem.  All machines are up-to-date with .Net 3.5, which is what I originally thought was causing it.  I’ve also provided a link to a simplified solution I’ve created that replicates the problem, viz. it will run fine on the development machine but taking the compiled DLL and EXE to another machine generates an error unless the DLL is compiled with the option to “Use MFC in a Static Library.”

Here is the link:
https://oncourse.iu.edu/access/content/user/angleton/Filemanager_Public_Files/DLL%20Problem/DLL%20Problem.zip

推荐答案

是什么使您认为不需要MFC?当您选择在静态库中使用MFC"时,它起作用的原因是:是因为它链接到dll本身.如果您使用共享库",则该库也必须位于目标计算机上.
What makes you think that MFC is not required? The reason why it is working when you select "Use MFC in a static library" is because it is linked into the dll itself. If you use "shared library", the library needs to be on the target computer as well.


这篇关于为什么需要将非MFC DLL编译为“在静态库中使用MFC"才能在VB中引用它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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