473,394 Members | 1,781 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

SEHException Exception from a COM component

I have a COM based component that raises an exception and I'm awaiting a
patch for it. However, I need to be able to recover from the exception,
destroy the COM object and then regenerate it @ a later date in my C# Windows
Forms App.

I presently do this:

System.Runtime.InteropServices.Marshal.ReleaseComO bject(obj);
obj = null;
System.GC.Collect(0);

However, it is not fully releasing the object

Any thoughts???
Nov 22 '05 #1
3 1605
cneff78,
Give this a try.
while (System.Runtime.InteropServices.Marshal.ReleaseCom Object(obj) > 0);
obj = null;
System.GC.Collect();
System.GC.WaitForPendingFinalizers();

Jason Newell, MCAD
Software Engineer
cneff78 wrote:
I have a COM based component that raises an exception and I'm awaiting a
patch for it. However, I need to be able to recover from the exception,
destroy the COM object and then regenerate it @ a later date in my C# Windows
Forms App.

I presently do this:

System.Runtime.InteropServices.Marshal.ReleaseComO bject(obj);
obj = null;
System.GC.Collect(0);

However, it is not fully releasing the object

Any thoughts???

Nov 22 '05 #2
Thank you for your quick reply

I implemented the code snippet you sent me but I'm still getting the same
error. However, I can see where what you were doing in your snippet was a
better handling of the COM clean-up. Thanks again for your help.
"Jason Newell" wrote:
cneff78,
Give this a try.
while (System.Runtime.InteropServices.Marshal.ReleaseCom Object(obj) > 0);
obj = null;
System.GC.Collect();
System.GC.WaitForPendingFinalizers();

Jason Newell, MCAD
Software Engineer
cneff78 wrote:
I have a COM based component that raises an exception and I'm awaiting a
patch for it. However, I need to be able to recover from the exception,
destroy the COM object and then regenerate it @ a later date in my C# Windows
Forms App.

I presently do this:

System.Runtime.InteropServices.Marshal.ReleaseComO bject(obj);
obj = null;
System.GC.Collect(0);

However, it is not fully releasing the object

Any thoughts???

Nov 22 '05 #3
cneff78,
Where does the exception get thrown? Obviously you cannot prevent the
exception but you can control how you deal with it by using
try...catch...finally... block.
How are you validating that the COM object is not getting released? Are
you able to recreate the object once it has thrown the exception.
You might get more answers with a little more detail.

Jason Newell, MCAD
Software Engineer

cneff78 wrote:
Thank you for your quick reply

I implemented the code snippet you sent me but I'm still getting the same
error. However, I can see where what you were doing in your snippet was a
better handling of the COM clean-up. Thanks again for your help.
"Jason Newell" wrote:

cneff78,
Give this a try.
while (System.Runtime.InteropServices.Marshal.ReleaseCom Object(obj) > 0);
obj = null;
System.GC.Collect();
System.GC.WaitForPendingFinalizers();

Jason Newell, MCAD
Software Engineer
cneff78 wrote:
I have a COM based component that raises an exception and I'm awaiting a
patch for it. However, I need to be able to recover from the exception,
destroy the COM object and then regenerate it @ a later date in my C# Windows
Forms App.

I presently do this:

System.Runtime.InteropServices.Marshal.ReleaseC omObject(obj);
obj = null;
System.GC.Collect(0);

However, it is not fully releasing the object

Any thoughts???

Nov 22 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: MJB | last post by:
I never get the above exception in Windows 2k. It only happens in Windows XP, which is the first oddity. My application is multi-threaded and I use the webbrowser control and media player. The...
0
by: Carsten | last post by:
Hi, I have a problem with instantiating a Web service. When the constructor for the proxy is called a SEHException is thrown. The call stack is shown below: ...
3
by: cneff78 | last post by:
I have a COM based component that raises an exception and I'm awaiting a patch for it. However, I need to be able to recover from the exception, destroy the COM object and then regenerate it @ a...
0
by: Robert Mayr | last post by:
Hello, i know that this is a bug of the .net framework, when you activate the VisualStyles, so i deactivate this features. But i get sometimes this exception when i call <Form>.ShowDialog (not...
0
by: Droopy | last post by:
Hi, I am working for a few month on a C# project (mixed dll for calling C++ legacy code with a C# wrapper). Since this morning, I can't start my application anymore ! I got a...
0
by: Ken Durden | last post by:
I'm getting the following exception coming out of a block of unmanaged C++ code. Thread executed for 1.03 sec and died with the following exception: External component has thrown an exception. ...
3
by: Chris | last post by:
Hi As I understand things, when my unmanaged C++ code throws an exception it is wrapped into a SEHException when it reaches managed code. Now is there a way from the managed catch clause to get...
0
by: mohit | last post by:
Hello, I am running my windows application on a 64 bit machine with MS .NET Framework 2.0 (x64). When using the FolderBrowserDialog an unhandled exception was coming time and again. After...
0
by: =?Utf-8?B?VGhvbWFzIFR1dGtv?= | last post by:
An ASP.NET web project has recently began crashing WebDev.WebServer.exe with a System.Runtime.InteropServices.SEHException. The EventLog for the crash looks like this: Application ID:...
0
by: THEDuke141 | last post by:
Hi guys, I've lately been plagued with a SEHException while trying to debug VB.Net applications. I'm not exactly sure when the problem started to appear but it literally just appeared out of...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.