|
-
Sep 23rd, 2008, 09:16 AM
#1
Thread Starter
Addicted Member
[2005] Marshal.ReleaseComObject
Hi all,
I have a COM component on my test server that my application uses to connect to a database.
I am trying to set up a single class to interact with the object. I am using the Marshal.ReleaseComObject method to "free up" the object once I'm done with it.
The problem is that this works the first time, but doesn't work on subsequent tries. Am I using the method improperly?
For example, in one of my classes, I send an SQL statement to the function that executes the queries, the query is executed, then I call the function to release the object. However, if I try to execute another query, I get nothing. Am I using this wrong?
I hovered over the top of the class where I instantiate the object, and I get a "Attempted to read or write protected memory...." error.
edit: I should note this is a web application, but I'm not sure if that matters. If so, mods feel free to move this to the appropriate section.
If my post helped you, please rate it!
Languages: VB/ASP.NET 2005, C# 2008,VB6
Databases: Oracle (knowledge not currently in use), DB2
FROM Customers
WHERE We_Know_What_We_Want <> DB.Null
SELECT *
0 rows returned
-
Sep 23rd, 2008, 09:39 AM
#2
Addicted Member
Re: [2005] Marshal.ReleaseComObject
I have never had much luck with Marshal.ReleaseComObject by itself. In VS 2003, it was recomended to use Marshal.ReleaseComObject in a loop until your reference count was zero.
Code:
While System.Runtime.InteropServices.Marshal.ReleaseComObject(o) > 0 End While
VS 2005 now has a method to do the looping for you.
Code:
System.Runtime.InteropServices.Marshal.FinalReleaseComObject(o)
Try using this method for your release.
Shut up and eat your banana!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|