【发布时间】:2011-05-04 15:41:16
【问题描述】:
我一直在努力编写一个从 c++ win32console 和 c++ dll 中提取的解决方案。我终于设法让他们在没有链接器错误的情况下交谈(所以我假设两者都是完全托管的 c++/CLI 项目)但是当我运行控制台时,我得到了以下错误。
在 0x03f71849 处未处理的异常 Company.Pins.Bank.Win32Console.exe: 0xC0000005:访问冲突写入 位置 0x00000001。
控制台还显示以下内容
未处理的异常: System.NullReferenceException:对象 引用未设置为 目的。在 c:...\win32console.cpp:line 中的 wmain 20 在 _wmainCRTStartup()
但我假设这是因为未处理的异常。
跟踪这个错误,我可以在下面的代码块中执行返回时发生错误。 (return 链接的方法似乎可以通过,只是返回时似乎变坏了。) .
#ifdef WPRFLAG
int wmainCRTStartup(
#else /* WPRFLAG */
int mainCRTStartup(
#endif /* WPRFLAG */
#endif /* _WINMAIN_ */
void
)
{
/*
* The /GS security cookie must be initialized before any exception
* handling targetting the current image is registered. No function
* using exception handling can be called in the current image until
* after __security_init_cookie has been called.
*/
__security_init_cookie();
return __tmainCRTStartup();
}
#include "stdafx.h"
#include "UInstruction.h"
#define DllExport __declspec(dllexport)
#define DllImport __declspec(dllimport)
using namespace System;
编辑:win32console.cpp 代码如下。
//int main(array<System::String ^> ^args)
int _tmain(int argc, _TCHAR* argv[])
{
auto P2 = (TCHAR *)"3 Barrowstead";
TCHAR* P3 = (TCHAR *)"3 Barrowstead";
double* P1;
P1[0] = 13;
UserInstruction(P1, P2, P3);
}
【问题讨论】:
-
您介意分享
win32console.cpp吗? -
我添加了代码,但它从未在断点处到达它。这可能意味着我为了让它工作而弄坏了一些东西。
标签: visual-studio-2010 visual-c++ c++-cli tchar