473,406 Members | 2,713 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,406 software developers and data experts.

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 1422
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
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
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
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
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
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
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
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
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
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
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
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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:
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
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
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.