G
Guest
Hi all,
Im attempting to use a COM class in C# via .NET interop. The class has two
modes - synhrounous and asynchronous. The mode is determined by the use (or
not) of an optional out parameter:
COMClass test = new COMClass();
object results = null;
test.DoWork(arg1, arg2, out results); //synchronous call - results are in
results after execution.
test.AsyncReturn += eventhandler;
test.DoWork(arg1, arg2, out null); //asynchronous call - fires
test.AsyncReturn.
Im sure you can see the problem here - the third out argument cannot be
null. Neither can Type.Missing or Reflection.Missing.Value - these are both
readonly fields. Omitting the out results in a type error. If I try:
object results = Type.Missing;
test.DoWork(arg1, arg2, out results);
then the call is synchonous, no calls are made to the eventhandler and there
is data in results after the call. Is there any way of specifying an
optional out parameter as not being there?
Thanks in advance!
Spammy
Im attempting to use a COM class in C# via .NET interop. The class has two
modes - synhrounous and asynchronous. The mode is determined by the use (or
not) of an optional out parameter:
COMClass test = new COMClass();
object results = null;
test.DoWork(arg1, arg2, out results); //synchronous call - results are in
results after execution.
test.AsyncReturn += eventhandler;
test.DoWork(arg1, arg2, out null); //asynchronous call - fires
test.AsyncReturn.
Im sure you can see the problem here - the third out argument cannot be
null. Neither can Type.Missing or Reflection.Missing.Value - these are both
readonly fields. Omitting the out results in a type error. If I try:
object results = Type.Missing;
test.DoWork(arg1, arg2, out results);
then the call is synchonous, no calls are made to the eventhandler and there
is data in results after the call. Is there any way of specifying an
optional out parameter as not being there?
Thanks in advance!
Spammy