473,545 Members | 1,956 Online
Bytes | Software Development & Data Engineering Community
+ 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 1429
IMO you'll have to call ReleaseComObjec t :
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******** *****@TK2MSFTNG P14.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
3481
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, const Bytef *source, uLong sourceLen); It is meant to be called by C, but I would rather use it from C#. So I wrote the following C# program to...
12
1592
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 mp); STRMAP *mp; //unmamaged object
8
3604
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 C# program. When I look at the reference and I double click to view it in the objec browser , I see only structs , without their members. And I...
3
2201
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 namespace ManagedWrappers { public __gc MClass1
5
1722
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
2251
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 "server.h" with a namespace server. When I include this file in another file that will be compiled as managed, the compiler gives me the following error: ...
3
2760
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 question.
8
1270
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 value. The return type in unmanaged DLL is LPSTR (tried LPTSTR too). There are no in/out params in the functions, just a return value. The second time...
6
4097
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 memory management and connection pooling constructs) as static variables which were intended to scoped to the process. 2. Managed C++ assemblies...
9
3533
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 3rd party unmanaged DLL will pass this reference into standard Win32 unmanaged static callback function in my code. Inside this unmanaged callback...
0
7415
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7675
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7928
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
4963
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3470
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3451
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1902
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 we have to send another system
1
1030
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
726
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.