Looking for a help with com server on C++.
Here is C# client code to invoke method:
public static object ComInvoke(string method, params object[] args)
{
return _comObj.GetType().InvokeMember(method, BindingFlags.InvokeMethod, Type.DefaultBinder, _comObj, args);
}
This is how I call it:
string[] result = (string[])ExplorerCore.ComInvoke("CopyFiles", new object[]{"arg1_1", "arg1_2"}, "arg2");
I always get the COMException: HRESULT: 0x80020008 (DISP_E_BADVARTYPE)).
Here is C++ getting method:
STDMETHODIMP CopyFiles(BSTR ** src, BSTR dest, BSTR ** result);
And the .IDL file interface declaration:
HRESULT CopyFiles([in, string] BSTR ** src, [in, string] BSTR dest, [out, retval] BSTR ** test);
Edit 1: This is correct code (without arrays):
C#:
string[] result = (string[])ExplorerCore.ComInvoke("CopyFiles", "arg1", "arg2");
C++
STDMETHODIMP CopyFiles(BSTR src, BSTR dest, BSTR* result);
IDL:
HRESULT CopyFiles([in, string] BSTR src, [in, string] BSTR dest, [out, retval] BSTR* test);
Thank you. Andrew
object[](containing twostrings) and astring. And you say this works. Does the comment following that block mean that if you change the first argument to astring[], it fails?object[],string), but not when you pass (string[],string)?string,string) and Im stuck with trying to pass (string[],string). To pass an array I added "**", but type mismatch... Sorry for my english, I know it may be hard to understand what am I trying to sayobject[],string) (that's what your second code block does). Your post doesn't say anything about passing (string,string).