私は、c++ win32console と c++ dll から抜け出すソリューションを書くのに苦労しています。私は最終的にリンカエラーなしでそれらを話すことができました(したがって、両方が完全に管理されたC ++ / CLIプロジェクトであると想定しています)が、コンソールを実行すると次のエラーが発生します。
Company.Pins.Bank.Win32Console.exe の 0x03f71849 で未処理の例外: 0xC0000005: アクセス違反の書き込み場所 0x00000001。
コンソールには以下も表示されます
未処理の例外: System.NullReferenceException: オブジェクト参照がオブジェクトのインスタンスに設定されていません。c:...\win32console.cpp:line 20 の wmain で _wmainCRTStartup()
しかし、これは未処理の例外が原因であると想定しています。
このエラーを追跡するだけでなく、以下のコード ブロックで return を実行するとエラーが発生します。(return でリンクされたメソッドは問題なくステップ スルーしているように見えますが、return がうまくいかないようです。)念のために言っておきますが、以下のコードは自分で書いたのではなく、Visual Studio によって生成されたものです。
#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);
}