2.0- VB.NET Interop Issue

  • Thread starter Christopher H. Laco
  • Start date
C

Christopher H. Laco

Long story longer, I'm tearing my hair out trying to get some of my
assemblies to work in ASP/COM. I have 4 classes/assemblies:

#1. CustomerMembershipProvider (Inherits MembershipProvider)
#2. CustomTcpClient (Inherits TcpClient)
#3. ASPFormsAuthentication (does magic to read/write
FormsAuthenticationTickets in ASP 3.0)
#4. ASPMembership (does magic to use Membership API within ASP 3.0)

Now, all of these assemblies are set to "Make assembly COM-Visable" and
"Register for COM Interop". Everything build and registers just fine.


Now, from with ASP, I can Server.CreateObject #3 and #4.
Server.CreateObject for #1 and #2 simply yield me:
Server object error 'ASP 0177 : 80131509'
Server.CreateObject Failed
/Default.asp, line 35
80131509

While the ASPMembership class can be created under COM, the minute it
trys to return a CustomMembershipProvider from itself, the page also
bails with the same error above.

Now, after some tinkering, I noticed the common ground here is that #1
and #2 Inherit something else while #3 and #4 don't.

Clearly there is some COM Interop/InteropServices/Inferace magic I'm
missing. What do I have to do to get these things expoed to COM and
actually working?

It is just the fact that the auto generated iterop stuff doesn't guess
correctly, and I should build and interface for those classes that
inherit other things so .NET knows what to expose?

-=Chris
 
C

Christopher H. Laco

Christopher said:
Long story longer, I'm tearing my hair out trying to get some of my
assemblies to work in ASP/COM. I have 4 classes/assemblies:

#1. CustomerMembershipProvider (Inherits MembershipProvider)
#2. CustomTcpClient (Inherits TcpClient)
#3. ASPFormsAuthentication (does magic to read/write
FormsAuthenticationTickets in ASP 3.0)
#4. ASPMembership (does magic to use Membership API within ASP 3.0)

Now, all of these assemblies are set to "Make assembly COM-Visable" and
"Register for COM Interop". Everything build and registers just fine.


Now, from with ASP, I can Server.CreateObject #3 and #4.
Server.CreateObject for #1 and #2 simply yield me:


While the ASPMembership class can be created under COM, the minute it
trys to return a CustomMembershipProvider from itself, the page also
bails with the same error above.

Now, after some tinkering, I noticed the common ground here is that #1
and #2 Inherit something else while #3 and #4 don't.

Clearly there is some COM Interop/InteropServices/Inferace magic I'm
missing. What do I have to do to get these things expoed to COM and
actually working?

It is just the fact that the auto generated iterop stuff doesn't guess
correctly, and I should build and interface for those classes that
inherit other things so .NET knows what to expose?

-=Chris

For the curious, I've solved this problem (I think).
The key was that all classes that failed Inherited something else. THat
meant a lot of guessing for regasm when generating the typelib.

I created a custom interface for the classes in question. Then I set the
ComDefaultInterface attribute to use the custom interface. Whola. No
more guessing and it works from ASP/COM.

There's probably something in the massive docs about this type of
scenerio, but it would be nice if Interop docs basically said this is
preferred practice on and class that inherits from another...

-=Chris
 
G

Guest

Christopher,

Thanks a million for posting this solution, we have been working late nights
for a week to get our site upgraded to ASP.Net 2.0 and this helped us solve
our last showstopper issue at the 11th hour.

Max Lancaster
Senior Developer
The Motley Fool
www.fool.com
 
Top