VB6 COM+ Component kills ASP .Net app 
Author Message
 VB6 COM+ Component kills ASP .Net app

VB6 COM Component that returns a string when called.

I have referenced it in my VB .Net (2003) project... The first time I call
it works, but on the second and up, it fails to come back to my code (I have
to click stop)

It is as if .Net never really frees the Component (Which needs to be done..)

What am I missing?

Adam Southerland

Notes:
I have tried adding
imports System.EnterpriseServices

wrapped around the COM+ instance I have...

Dim Config as new ServiceConfig
ServiceDomain.Enter(config)
Dim onjCOMOBJ as COMOBJ.CLS = New COMOBJ.CLS
Dim myStr as string = objCOMOBJ.Function
ContextUtil.SetComplete()
ServiceDomain.Leave()

Before I added the imports and Service stuff it did the same thing - i'm
flying blind =(



Mon, 10 Oct 2005 06:53:21 GMT  
 VB6 COM+ Component kills ASP .Net app
inline

Quote:
> VB6 COM Component that returns a string when called.

> I have referenced it in my VB .Net (2003) project... The first time I call
> it works, but on the second and up, it fails to come back to my code (I
have
> to click stop)

> It is as if .Net never really frees the Component (Which needs to be

done..)

The RCW for the COM object will not decrement the reference count on the COM
component (and thus destroy the object) until it is Garbage Collected.

You can force the reference count to 0 with
system.Runtime.InteropServices.Marshal.ReleaseComObject.

So the VB6 code:

function getStuff() as string
 Dim objCOMOBJ as COMOBJ.CLS
 set objCOMOBJ = New COMOBJ.CLS
 getStuff = objCOMOBJ.Function
 set objCOMOBJ = nothing
end sub

is most closely translated by

the VB7 code:

function getStuff() as string
 Dim objCOMOBJ as New COMOBJ.CLS
 try
  return objCOMOBJ.Function()
 finally
   system.Runtime.InteropServices.Marshal.ReleaseComObject(objCOMOBJ)
 end try
end sub

.

David



Mon, 10 Oct 2005 07:28:20 GMT  
 VB6 COM+ Component kills ASP .Net app
Thanks - Exactly what I was needing!



Quote:
> inline


> > VB6 COM Component that returns a string when called.

> > I have referenced it in my VB .Net (2003) project... The first time I
call
> > it works, but on the second and up, it fails to come back to my code (I
> have
> > to click stop)

> > It is as if .Net never really frees the Component (Which needs to be
> done..)

> The RCW for the COM object will not decrement the reference count on the
COM
> component (and thus destroy the object) until it is Garbage Collected.

> You can force the reference count to 0 with
> system.Runtime.InteropServices.Marshal.ReleaseComObject.

> So the VB6 code:

> function getStuff() as string
>  Dim objCOMOBJ as COMOBJ.CLS
>  set objCOMOBJ = New COMOBJ.CLS
>  getStuff = objCOMOBJ.Function
>  set objCOMOBJ = nothing
> end sub

> is most closely translated by

> the VB7 code:

> function getStuff() as string
>  Dim objCOMOBJ as New COMOBJ.CLS
>  try
>   return objCOMOBJ.Function()
>  finally
>    system.Runtime.InteropServices.Marshal.ReleaseComObject(objCOMOBJ)
>  end try
> end sub

> .

> David



Mon, 10 Oct 2005 21:23:59 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Problem passing VB COM+ ASP Request object to .NET component System.Web.HTTPRequest through COM interop

2. Problem using a UNC Path within a COM component in asp.net

3. COM Interop - using .NET component in VC6 client app

4. VB6 COM+ ASP Component Issues

5. Can't debug ASP/COM components from VB6

6. Debugging ASP/COM+ components from VB6

7. Can you use the Server object from ASP in a COM VB6 Component

8. Using VB6 COM component in .NET Problems (Beta2)

9. Forms in COM Component behave differently when called from VB6 or VC++6 Apps

10. ASP.NET App v. VB.NET App

11. Conversion of VB.Net App to ASP .Net App

12. VB6/ASP vs .NET/ASP.NET development

 

 
Powered by phpBB® Forum Software