Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
ASP.NET Page Not Releasing COM Object
Message
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
00754450
Message ID:
00754529
Views:
18
Hi Steve,

The reason why you don't see the reference count increase is because the garbage collection hasn't kicked in yet to release the reference to the COM object. Even though you set the reference to null, the object still is not destroyed until the garbage collection comes through and clears out objects no longer referenced. If .NET needs to call COM, then a RCW (Runtime Callable Wrapper) is generated. A RCW is a wrapper for COM objects that's callable by the runtime. It's created on the garbage collection heap, and so is subject to the runtime's garbage collection, which is what all runtime objects expect, and it also maintains an internal reference count for the COM object the managed object is calling. The GC keeps track of the number of references that an object has, and when that object is no longer referenced, it flags it for garbage collection.

>I created a VFP MTDLL that does some fairly simple operations. I added it to my ASP.NET project, compiled everything, it runs fine.
>
>If I hit [F5] in the browser to refresh, things still come back fine.
>
>However, if I hold down [F5] to 5-6 seconds to simulate a lot of concurrent requests, eventually I only see a blank page while "the IE ball spins". I have to restart IIS in order to get a good response again.
>
>Just to test things out further, I put the MTDLL inside a COM+ application and viewed the object reference count. I can see the reference count increase after I hold down [F5] in the browser, but the refs never decrease.
>
>I have the ASPCOMPAT="true" directive in the top of my .aspx page.
>
>My simple COM object test page looks like this:
>
>
>devcom.TestMeClass devCom = new devcom.TestMeClass();
>devCom.ProcessReq( _sWriter.ToString() );
>string retVal = devCom.OUTPUTFINAL.ToString();
>devCom = null;
>return retVal;
>
>
>Here is what is at the top of my MTDLL main.prg:
>
>#INCLUDE SC.H
>#INCLUDE VFP.H
>#DEFINE CRLF	Chr(13)+Chr(10)
>
>Define Class TestMe as Session OlePublic
>
>Function Init
>Local ;
>	pathString as String , ;
>	nothing as Variant
>	nothing = Sys(2340,1)
>	Set Cpdialog Off
>	Set Safety Off
>	Set Exclusive Off
>	Set Multilocks On
>	Set Deleted Off
>	Set Collate To "MACHINE"
>	Set Date to ANSI
>	Set Century On
>	Set Mark to "."
>	Set Near On
>	Set Exact Off
>	Set Ansi Off
>	Set TextMerge Delimiters To "{{","}}"
>	This.dllPath = Lower( JUSTPATH(_VFP.Servername) )
>	This.xDomDoc = CreateObject("Msxml2.FreeThreadedDOMDocument.4.0")
>	if ( Left(This.LoadConfig() , 1 ) ="!" )
>	Return .f.
>	endif
>	if ( This.SetTempDirectory() = "0" )
>	Return .f.
>	EndIf
>	pathString = ( This.dllPath )+ ";" + ( JustPath(This.dbcPath) )
>	Set Path to &pathString
>	Return .t.
>EndFunc
>
-----------------------------------------

Cathi Gero, CPA
Prenia Software & Consulting Services
Microsoft C# / .NET MVP
Mere Mortals for .NET MVP
cgero@prenia.com
www.prenia.com
Weblog: blogs.prenia.com/cathi
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform