トップ回答者
InvalidOperationException

質問
-
VC++からC#のDLLを呼ぼうとすると下記のエラーが出ます。
どなたかわかる方はいらっしゃらないでしょうか。
エラーを起こした関数がSTAでないといけないと言っていますが、この関数はVCライブラリの機能なので修正できません。
それよりももっといい方法がないでしょうか。よろしくお願いいたします。
【エラーメッセージ】
ハンドルされていない例外: System.InvalidOperationException: 呼び出しスレッドは、多数の UI コンポーネントが必要としているため、STA である必要があります。
場所 System.Windows.Input.InputManager..ctor()
場所 System.Windows.Input.InputManager.GetCurrentInputManagerImpl()
場所 System.Windows.Input.InputManager.get_Current()
場所 System.Windows.Input.KeyboardNavigation..ctor()
場所 System.Windows.FrameworkElement.FrameworkServices..ctor()
場所 System.Windows.FrameworkElement.EnsureFrameworkServices()
場所 System.Windows.FrameworkElement..ctor()
場所 System.Windows.Controls.Control..ctor()
場所 Execute1..ctor()
場所 main(String[] args) 場所 c:\documents and settings\togasa\my documents\visual studio 2008\projects\project1\cppmain\cppmain\cppmain.cpp:行 19
場所 mainCRTStartupStrArray(String[] arguments) 場所 f:\dd\vctools\crt_bld\self_x86\crt\src\mcrtexe.cpp:行 306【呼び出し元ソースコード】
// cppmain.cpp : メイン プロジェクト ファイルです。
#include "stdafx.h"
#using <mscorlib.dll>
#using <WindowsBase.dll>
#using <PresentationCore.dll>
#using <PresentationFramework.dll>#include <iostream>
#using "Execute.dll"
using namespace System;
int main(array<System::String ^> ^args)
{
printf("スタート\n");
Execute1^ p = gcnew Execute1();
int result = p->ConnectDB("日本", "ちゃちゃちゃ");
std::cout << "result = " << result << std::endl;
Console::WriteLine(L"Hello World");
return 0;
}です。