VS2008中如何使用VS2010内置的dll [英] How to use VS2010 built dlls in VS2008

查看:143
本文介绍了VS2008中如何使用VS2010内置的dll的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的工作中,我们有VS2008 。
项目中的一些合作伙伴我使用VS2010 (不能使用VS2008)

In my work we have VS2008. Some partners in the project I work, use VS2010 (can't use VS2008)

他们必须建立一个基于dll的我必须在我的框架中使用该DLL ...

They have to build a dll based and I have to use that dll in my framework...

我设法构建主应用程序并链接dll。
应用程序启动,并创建VS2010 dll的对象
,但是当我尝试删除这些对象时,应用程序崩溃...

I managed to build the main app and link the dll's. the app starts, and objects from the VS2010 dll's are created, but the app crashes when i try to delete these objects...


Windows已在app.exe中触发断点。这可能是由于
损坏的堆,这表示app.exe或任何
DLLs中已加载的错误。

Windows has triggered a breakpoint in app.exe. This may be due to a corruption of the heap, which indicates a bug in app.exe or any of the DLLs it has loaded.

有没有关于如何解决这个问题的想法?

Have you any ideas on how to fix this?

推荐答案

你的同事的DLL与VS2010的运行时库链接。您的代码与VS2008的运行库链接。

Your co-workers' DLLs are linked against VS2010's runtime library. Your code is linked against VS2008's runtime library.

当您从VS2010 dll中调用一些函数来分配一个新对象时,它将被分配到该库的堆上。当您在该对象上调用删除时,VS2008的运行库将尝试将其从自己的堆中释放出来。因为它们不一样,你会得到这个错误。

When you call some function from the VS2010 dll to allocate a new object, it will be allocated on that library's heap. When you call "delete" on that object, VS2008's runtime library will try to free it from its own heap. Since they're different, you get that error.

如果你打算混合这样的运行时,你需要VS2010 dll来公开对于每种类型,free() -style函数(只是C ++析构函数)。当混合像这样的运行时库(例如使用STL容器)或任何类型的写时复制对象时,还有其他一些事情您应该非常小心。一般来说,更容易避免。

If you're going to mix runtimes like that, you need the VS2010 dll to expose free()-style functions (not just C++ destructors) for each type. There are other things you should be very careful with when mixing runtime libraries like that, such as using STL containers, or any sort of "copy-on-write" objects. In general, it's easier to avoid it.

这篇关于VS2008中如何使用VS2010内置的dll的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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