Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / October 2004

Tip: Looking for answers? Try searching our database.

Static and IJW issues.....Help!!!!

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Luis Fajardo - 19 Oct 2004 21:19 GMT
I need to interface an old C application with C#.NET,  I created a IJW C++
bridge, here is a sample code ......

#include "stdafx.h"
#include "MyCPPClass.Interop.h"

#pragma managed
#using <mscorlib.dll>
#using "MyCSharpAssembly.dll"
using namespace System;
using namespace System::Runtime::InteropServices;
using namespace MyCSharpAssembly;

void ExecuteManageCode(char *msg, char **errMsg)
{
 try{
   MyCSharpAssembly::CSharpClass *cSharpClass = new
MyCSharpAssembly::CSharpClass();
   cSharpClass->set_Msg(msg);
   cSharpClass->Execute();
 }
 catch(Exception *e){
   *errMsg =
(char*)Marshal::StringToHGlobalAnsi(e->get_Message()).ToPointer();
 }
}

#pragma unmanaged
extern "C" {
 __declspec(dllexport) void __stdcall ExecuteUnManageCode(char *msg, char
**errMsg)
 {
   ExecuteManageCode(msg, errMsg);
 }
}

The code works fine and my C application is able to execute the C#.NET.  
However, I found some issues if my C#.NET uses STATIC methods.  The first
execution works fine but the following executions "hangs".  I know that the
memory created in the MANAGED section of my code is being release by the GC,
but what about STATICS?  How the Application Domain boundaries are being
handle during this type of IJW technology?  When is the memory used by those
STATICS being released?  If I replace the code that uses the STATIC methods
my application will never experience the issue that ocurrs when the STATIC
methods are being used.

Thanks in advance
Willy Denoyette [MVP] - 20 Oct 2004 22:04 GMT
Please post a short and complete program that illustrates the issue.
Statics are released when the application exits.
Willy.

>I need to interface an old C application with C#.NET,  I created a IJW C++
> bridge, here is a sample code ......
[quoted text clipped - 47 lines]
>
> Thanks in advance
Luis Fajardo - 21 Oct 2004 03:19 GMT
Thanks for the information about the Statics.  Actually my problem was a
little deeper and nothing to do really with the Static itself.  I ran onto
some threading problems that I got it to work.

Thanks

> Please post a short and complete program that illustrates the issue.
> Statics are released when the application exits.
[quoted text clipped - 51 lines]
> >
> > Thanks in advance

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.