Home All Groups Group Topic Archive Search About


Author
12 Jun 2006 6:42 PM
bseddon
Jason Rowland wrote:
> [B]I created a .NET assembly and made it accessable as a COM object. > When I
> tried to instantiate it in an ASP page, I got error '80131509'.  

This reply is being posted (two years too late) because I ran into the 80131509 problem and this post is the most frequently presented by Google in response to this error number.  However the thread doesn't (didn't) contain an answer. Having spent two hours cracking the problems, others might save a bit of time knowing an answer.

Like Jason I have a .NET (C# as it turns out) assembly that exposes a class as a COM object.  When used from an Excel add-in (written in VB) the class works.  But if the COM class exposed by the assembly is instantiated from a .vbs script or even a VB program an 80131509 error is raised.  When I put message boxes in the class constructor I could see that the constructor runs successfully but that the error is raised after - so reason suggests that it was not a code problem.

After stripping out ALL the code, the only slightly unusual thing left was that the exposed class inherits from a base class.  Because I don't want the base class exposed to COM it was decorated with [ComVisible(false)].  When I finally removed this decoration from the base class the COM class worked in VB and in scripts.

So it seems mscorlib does not want to expose a .NET class to COM if it's base class is not visible.  My lesson is that classes which are to be exposed should not inherit.  They should single classes that delegate to a contained instance of the class that really does the work. -- bseddon ------------------------------------------------------------------------ Posted via http://www.codecomments.com ------------------------------------------------------------------------

AddThis Social Bookmark Button