_CrtIsValidHeapPointer [VC++ 2005 CLR]

原因CLR程序在加载本地Dll时,运行Debug程序时提示异常错误,Release时可以运行,不崩溃。

解决方法:在项目属性中设置

1. Set Linker/Advanced/Entry Point to "" (empty string)
2. Set Linker/System/Subsystem to Not Set

结果:It's possible to change a windows forms application to run as a console one. The down side is that a console window pops up. The up side is that the application runs fine.

[转自]http://www.cnblogs.com/sunrack/articles/588115.html

 

The reason why you get this error is that a winforms application has a managed entry point. The initialization of the native global objects is done by the CRT (C RunTime) startup routine. Since in this case there is no CRT startup routine the MyBoard global object fails to initialize correctly.

This issue looks very similar to the issue reported here http://lab.msdn.microsoft.com/ProductFeedback/viewFeedback.aspx?feedbackid=f4674f22-1382-492a-a2d6-1539dc50bf82.

If possible, always include the call-stack from the point you get the assert. This will greatly help the investigation. In this case, you can see that the call stack originates from the managed startup code.

I am assuming that you are compiling your app as /clr and your static library is compiled native. The following is a workaround solution to make the debug assertion fail message go away. You can see this workaround at http://lab.msdn.microsoft.com/ProductFeedback/ViewWorkaround.aspx?FeedbackID=FDBK44086#1

Workaround Steps:
In the project properties:

1. Set Linker/Advanced/Entry Point to "" (empty string)
2. Set Linker/System/Subsystem to Not Set

Step 1: Makes sure that the CRT startup code is invoked. This is because, if no entry point is specified, the linker will automatically use mainCRTStartup, which is defined in the CRT libraries. mainCRTStartup will make sure that the global object is initialized correctly.

Step 2: Makes sure that the linker will look for the symbol “main”. The linker looks for “main” because mainCRTStartup calls main() in its body. The default option for a Winforms application is Subsystem:Windows and this makes the linker look for WinMain().

http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=101712

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值