Re: Calling COM functions using IDispatch->Invoke(...
Hi, Sven
May be something is fundamentally wrong with this COM server, I mean
this third party gave me example of the code not just in VB, but in C#
also:
Example 1:
static void Main(string[] args)
{
using(DispatchObject comObj = new
DispatchObject("SomeCOM.SomeInterface"))
{
comObj.InvokeMethod("Start", @"C:\\..path");
//exception thrown
Examle 2:
object comObj = null;
try
{
comObj = System.Activator.CreateInstance(
Type.GetTypeFromProgID("SomeCOM.SomeInterface", true));
comObj.GetType().InvokeMember("Start",
System.Reflection.BindingFlags.InvokeMethod,
null,
comObj,
new object[] { @"C:
\\=85path " }
);
//exception thrown
I.e. even the examples in C# they provided, do not work =96 the program
crashes, though example in VB works fine ?! The only thing I've
noticed, both their examples in VB and C# using only one parameter
=93Path=94 for this method =93Start=94, though as I've mentioned at the ve=
ry
beginning prototype, that I can see in .tlh file has two parameters=85
But I've tried already use only one parameter in dispparams structure,
the result is the same=85
Anyway thanks again for trying help me,
Alex
On Apr 22, 3:49 pm, "SvenC" <Sv...@nospam.nospam> wrote:
Hi Alex,
EXCEPINFO parameter says:
"Failed to initialize SomeCOM library"
When I look at this line:
hr = CoCreateInstance( clsid,
NULL, CLSCTX_LOCAL_SERVER,
IID_IDispatch,
(void**)&pIDispatch
I'd say that you disallow inproc COM objects.
Try CLSCTX_ALL.
--
SvenC