[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.interop

TargetInvocationException and COM

hammad.awan_nospam@gmail.com

7/5/2007 10:57:00 PM

Hello,

I have created a ComVisible class in one assembly. This class is used
to create intances of types and then return them. For example, it
exposes a function called LoadType which takes an assembly path and
the type name, and creates an instance of the class.

When this ComVisible class is used in javascript to load an instance
of a class that is marked as COM visible in one assembly that
references another type defined in another assembly that is marked as
COM visible, the LoadType fail calls with a
TargetInvocationException. However, if I comment out the code that
references the type defined in the latter, LoadType works fine.

In other words, class A is ComVisible and exposes a COM interface with
a method called LoadType. This class is defined in its own assembly
X.

Class B is ComVisible and defined in its own assembly Y.

Various types such as classes and enums are defeined in another
assembly Z.

If Class B has a member of a type defined in assembly Z, and I try to
call LoadType to create an instance of class B using an instance of
class A (which is COM object) in javascript, the call fails with a
TargetInvocationException.

However, if I remove that reference to the type defined in assembly Z
and I try to call LoadType to create an instance of class B using an
instance of class A in javacript, the call succeeds and the object is
returned.

Why does this happen?

Thanks.