こんにちは、これを読んでくれてありがとう。
VS2010 でソリューションをデバッグする際に問題が発生しました。より具体的には、次の設定があります。
- すべてが Windows 7、64 ビット用にコーディングされています
- サード パーティの EXE (c++) は、C# を介してその API を公開します。
- 私のプラグイン (c#) は、混合モードの dll を呼び出します
- 混合モードの dll は、ネイティブの c++ を呼び出します
- ネイティブ c++ dll は、他のプログラム (ネイティブ c++ も) 用に既に作成された多くの製品コードを呼び出します。
- ネイティブ C++ dll は、別の混合モード dll も呼び出し、それが ac# dll を呼び出します
- VS2010 で作成およびコンパイルされたすべてのもの
奇妙なことは次のとおりです。
- マネージド コードをデバッグすると、すべて正常に動作します。例外なく
- ネイティブ コードをデバッグすると、c++ が混合モード dll を呼び出すときにランダムな例外 (0xe0434352) が発生します (これは、実際には c# dll のコードのインターフェイスです)。
- 例外ウィンドウ (最初のチャンス) がポップアップしたら、スキップ/続行を押しますが、それ以上のデバッグはできません。プログラムの実行結果は同じですが
- 混合モード コードの呼び出しをコメント アウトすると、問題は解決します。
編集:
プロダクションコードの投稿は少し慎重です。例外は、上で述べた一般的なものです。例外ウィンドウには文字通り次のように表示されます。
- Revit.exe: 0xe0434352: 0xe0434352 で例外 (最初のチャンス) が発生しました。
- Revit MEP 2013 です。
KernelBase.dll!000007fefd8f9e5d()
[Unten angegebene Rahmen sind möglicherweise nicht korrekt und/oder fehlen, keine Symbole geladen für KernelBase.dll]
clr.dll!000007fee65c4e13()
clr.dll!000007fee65c597e()
000007fe898bad42()
000007fe898b65be()
000007fe898b646b( )
000007fe898b6144()
000007fe898b5fa3()
000007fe898b5d4b()
clr.dll!000007fee644f2ee()
RevitClient.dll!RvtToMyProg::getPropMappedValue(std::basic_string,std::allocator > & Res="", int Sel=0, DigitalModelMapping & DigiModMap={...}, const CadElem & Elem={...} , std::basic_string,std::allocator > & Prop="NAME") Zeile 721 + 0x8d バイト C++ RevitClient.dll!RvtToMyProg::addElementAttributes(int Sel=0, const CadElem & CadElem={...}, DigitalModelMapping & DigiModMap={...}, const Descriptor * EntDesc=0x000000003ace72b0, Entity * XDataEnt=0x0000000056ad70a0) Zeile 630 + 0x75 バイト C++ RevitClient.dll!RvtToMyProg::dataToMyProg(DigitalModelMapping & DigiModMap={...}, std:: set > >,std::less > > >,std::allocator > > > > & Classnames=3, Descriptor & ModDsc={...}, XDataModel & XData={...}) Zeile 575 + 0x46 バイト C++ 000007fe898a7aa3()
000007fe898a79eb()
000007fe898a7837()
000007fe898a5aef()
000007fe898a5624()
clr.dll!000007fee644f2ee()
RevitAPIUILink.dll!0000000033c31bfb()
RevitAPIUILink.dll!0000000033c326d8()
DesktopMFC.dll!00000000007e1843()
000007fe898a471e()
000007fe898a044f()
000007fe8989ff7b()
000007fe8989fc3e()
000007fe89892e9d()
000007fe89892d33 ()
000007FE87D0DA2A()
000007FE87D0D81B()
000007FE89892B1A()
000007FE87D0D2E6() 000007FE87D0CA76
( ) 000007FE87D09555A() 000007FE8989FAMFAMPATIN
000007fe89852427()
000007fe87d0d2e6()
000007fe87d0ca76()
000007fe898439be()
000007fe87d0d2e6()
000007fe87d0ca76()
000007fe87d0955a()
000007fe896da930()
000007fe8943dbb8()
000007fe8943cbcb()
000007fe8943c84f()
000007fe896d3520()
000007fe8796a6d8()
000007fe8796a261()
000007fe873b09ae()
000007fe873b087c()
000007fe873b06f5( )
000007fe873b0507()
000007fe873afee7()
000007fe873acd2e()
000007fe873ac383()
clr.dll!000007fee644f2ee()
user32.dll!0000000077919bd1()
user32.dll!00000000779198da()
user32.dll!00000000779167c2()
mfc100u.dll!CWnd::IsDialogMessageW(tagMSG * lpMsg=0x0000000000000202) Zeile 198 C++ mfc100u.dll!CControlBar::PreTranslateMessage(tagMSG * pMsg=0x000000900abd6714) Zeile 445 + 0x2c CW Bytes C++ mfc100!Walklate__:WalklateNDu.dll hWndStop=0x000000000922e8a0, tagMSG * pMsg=0x0000000000000002) Zeile 3311 + 0x10 Bytes C++ mfc100u.dll!AfxInternalPreTranslateMessage(tagMSG * pMsg=0x0000000140003070) Zeile 233 + 0x15 Bytes C++ mfc100u.dll!AfxInternalPumpMessage() Zeile 178 + 0x12 Bytes C++ mfc100u.dll !cwinthread :: run()Zeile 634 C ++ MFC100U.dll!afxwinmain(hinstance__ * hinstance = 0x000000000000000001、hinstance __ * hprevinstance = 0x0000000000000000、wchar_t * lpcmdline = 0x0000000000 000のint 0x000000 000年のintcmdline = 0x000000 ()
kernel32.dll!00000000777f652d()
ntdll.dll!0000000077a2c521()
多分いくつかのサンプルコード:
c++: dostuff() { //it = std::list::iterator std::string = this->MixedMode->GetElementPropertyValue(Sel, it->Name, it->Api); } mixed mode: std::string RevitBridge::GetElementPropertyValue(int Sel, const std::string &Name, const std::string &ApiName) { String^ sName = gcnew String(Name.c_str()); String^ sApiName = gcnew String(ApiName.c_str()); String^ s = RevitUtils::GetElementPropertyValue(Sel, sName, sApiName); return std::string(msclr::interop::marshal_as<std::string>(s)); } c#: public String GetElementPropertyValue(int Sel, String Name, String ApiName) { if (Sel < 0) { return ""; } if (Name.Equals("_ElementID_")) { return this.GetElementID(Sel); } BuiltInParameter bip = BuiltInParameter.INVALID; try { bip = (BuiltInParameter)Enum.Parse(typeof(BuiltInParameter), ApiName); } catch (Exception) {} if (ApiName.Equals("INVALID") || BuiltInParameter.INVALID == bip) { return this.GetElemParamValueAsString_ByName(iters[Sel].Current, Name); } return this.GetElemParamValueAsString(iters[Sel].Current, bip); }
正しい方向に向けるアドバイスをいただければ幸いです。
ありがとう、コーネル