Xavier,
What I would do is I would get the type library that is associated with
the COM+ object, and get the interface defined in .NET. Once you have that,
you can just cast the instance that you create to the interface, and access
it normally (and it's faster as well).
If you can't do that, then you will have to use reflection, as you are
trying to do now.
In order to handle parameters passed by reference in COM, you need to
call the InvokeMember method on the Type, passing in the instance, as well
as a number of other parameters. The one that you have to pay attention to
here is the modifiers parameter. It will be an array of ParameterModifier
structures, which indicate which Parameters (indexed starting from zero)
have reference parameters which need to be marshaled back.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
-
mv*@spam.guard.caspershouse.com
"Xavier MT" <xm*****@hotmail.com> wrote in message
news:ut*************@TK2MSFTNGP10.phx.gbl...
Hi, I have a small problem I solve easily in VB.NET but now I need to
implement it in C#. The problem is:
I have a COM component written in C++ and the methods are like this:
STDMETHOD(get_OpeningBalance)(double *pVal);
In VB.NET I do the following:
MyLoanCalculator = CreateObject("LoanLib.Loan.1")
And then I use MyLoanCalculator normally and since VB allows latebinding I
can access all methods and properties easily. However when I use C# I use
Activator.CreateInstance but then I haven't been able to invoke properties
or methods that receive parameters by reference.
An important detail is that the COM library needs to be registered as a
server application in COM+.
Any ideas?