I have a method declared on an interface like so:
public interface IInterface
{
void DoSomething(string format, params object[] arguments);
}
I am dynamically loading a managed c++ class that uses an implementation of this interface. The interface and inmplementation are both C#.
IInterface^ foo = gcnew Implentation();
This call is fine:
foo->DoSomething("string", someParam);
This call fails:
foo->DoSomething("string");
It looks like if there are no parameters to pass it just can't resolve the method which should accept any number of params (including zero of course). I could probably use a nullptr as a placeholder but that's pretty ugly or I could add a superfluous overload of DoSomething(string format)
which isn't great either but better than making all calls more awkward than they should be.
Am I missing something or is this not supported? All the helpers on the internet show how to declare the params equivalent in c++ but that doesn't help in my scenario.
I can't replicate your problem.
Given the C# interface & implementation:
This C++/CLI code works fine:
Is there another element that is missing here? Or have I missed the point :)