473,480 Members | 1,585 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Using UnManaged Code in Managed code

Hi

I've a COM written in VC++ 6, and i'm using it in a C# project. I add the
Com reference in the refrences and in a method of a class of C# code, I
instantiate the COM object. Since this object is local to the function so it
should be distroyed as its scope finishes i.e. as the function body
finishes. and when the COM object destroys, its FinalRelease should be
called. I've written some cleanup code in this FinalRelease. that is
important to be executed on its release. But the problem is that the object
does not get destroyed here, rather it is destroyed when that C# application
ends. and then the FinalRelease is called. To make things worse, this C#
application is a non-stopping server type of application that does not get
exited, so the Object never gets released. It only gets released when I stop
this server manually. I want this FinalRelease to be called as soon as the
body of the C# function containing this object finishes. Is there any way I
can do this.

Please Help.

Thanx and Regards

Usman Jamil
Jul 21 '05 #1
1 1424
IMO you'll have to call ReleaseComObject :
http://msdn.microsoft.com/library/de...bjecttopic.asp

Remember that .NET does not have deterministic finalization...

Patrice

--

"Usman Jamil" <us***@advcomm.net> a écrit dans le message de
news:uz*************@TK2MSFTNGP14.phx.gbl...
Hi

I've a COM written in VC++ 6, and i'm using it in a C# project. I add the
Com reference in the refrences and in a method of a class of C# code, I
instantiate the COM object. Since this object is local to the function so it should be distroyed as its scope finishes i.e. as the function body
finishes. and when the COM object destroys, its FinalRelease should be
called. I've written some cleanup code in this FinalRelease. that is
important to be executed on its release. But the problem is that the object does not get destroyed here, rather it is destroyed when that C# application ends. and then the FinalRelease is called. To make things worse, this C#
application is a non-stopping server type of application that does not get
exited, so the Object never gets released. It only gets released when I stop this server manually. I want this FinalRelease to be called as soon as the
body of the C# function containing this object finishes. Is there any way I can do this.

Please Help.

Thanx and Regards

Usman Jamil

Jul 21 '05 #2

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

Similar topics

47
3478
by: Bonj | last post by:
I downloaded the gzlib library from zlib in order to do compression. (http://www.gzip.org/zlib) The prototype of the compression function seems to be int compress (Bytef *dest, uLongf *destLen,...
12
1587
by: MuZZy | last post by:
HI, Say i have a class(on C++) which has an unmanaged STL member of STRMAP which is a define for map<string, string>. class CL { public CL(){mp = new STRMAP()}; public void Dispose(delete...
8
3595
by: Mas L via DotNetMonster.com | last post by:
Hi, I have a c++ source code which I can compile to be a DLL (in VS.NET 2003). And I need to use it in a C# program. After I compiled/build the C++ code to a DLL, I add it as a Reference in my...
3
2193
by: mirek | last post by:
Hi, I've got problem building managed class library to wrap unmanaged code. I created managed class library using standard patten: #include "../Unmanaged/Class1.h" //Class1 unmanaged ...
5
1711
by: Andrew | last post by:
I want to use a managed c++ class from an unmanaged class. Here is my code: // *** Unmanaged Code // .h file class UnmanagedClass { public: // Other stuff here
1
2243
by: RaKKeR | last post by:
Hi, I'm trying to wrap my unmanaged c++ code into a managed c++ wrapper. The problem is VC .NET doesn't seem to find the namespaces defined in my unmanaged code. Let's say I have a file...
3
2753
by: Thorsten | last post by:
HI I'm a C# developer and unfortunately I have to write now some code in managed and unmanaged C++. In this area I'm Newbie and therefore please forgive me if this is a really simple...
8
1261
by: Ravneet | last post by:
I am trying to do some calls to unmanaged DLL that I have written. I am doing it in the Session_Start of my Global.asax.cs. The first time I call a function in my DLL it returns correct string...
6
4080
by: Stephen Walch | last post by:
Our application environment consists of three basic layers: 1. Third-party unmanaged DLLs that were written before the CLR was invented and maintain a significant amount of information (including...
9
3524
by: =?Utf-8?B?RWR3YXJkUw==?= | last post by:
I would greatly appreciate some help on passing managed object into unmanaged code. I need to pass a reference (address of) of a managed class into unmanaged code (written by a thrid party). The...
0
6908
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
7045
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
7087
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6741
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...
0
6944
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5341
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
2985
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1300
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
563
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.