diff --git a/csharp-api/REFrameworkNET/Method.cpp b/csharp-api/REFrameworkNET/Method.cpp index 58700d35b..60223cf4a 100644 --- a/csharp-api/REFrameworkNET/Method.cpp +++ b/csharp-api/REFrameworkNET/Method.cpp @@ -140,11 +140,10 @@ ::reframework::InvokeRet Method::Invoke_Internal(System::Object^ obj, array args2{}; + //std::vector args2{}; + std::array args2{}; // what function has more than 32 arguments? if (args != nullptr && args->Length > 0) { - args2.resize(args->Length); - for (int i = 0; i < args->Length; ++i) try { if (args[i] == nullptr) { args2[i] = nullptr; @@ -250,7 +249,9 @@ ::reframework::InvokeRet Method::Invoke_Internal(System::Object^ obj, arrayMessage); } - return m_method->invoke((reframework::API::ManagedObject*)obj_ptr, args2); + const auto argcount = args != nullptr ? args->Length : 0; + + return m_method->invoke((::reframework::API::ManagedObject*)obj_ptr, std::span(args2.data(), argcount)); } bool Method::HandleInvokeMember_Internal(System::Object^ obj, array^ args, System::Object^% result) {