Click here to Skip to main content
15,887,430 members
Home / Discussions / C#
   

C#

 
GeneralRe: C++ to C# stupid question??? Pin
Pet Lizard6-Jan-07 0:17
Pet Lizard6-Jan-07 0:17 
QuestionColumn Resize not executed if Control not visible? Pin
JoeRip5-Jan-07 15:12
JoeRip5-Jan-07 15:12 
QuestionHow to get a bitmap image from part of a larger bitmap? Pin
Subterranean5-Jan-07 13:29
Subterranean5-Jan-07 13:29 
AnswerRe: How to get a bitmap image from part of a larger bitmap? [modified] Pin
hpjchobbes5-Jan-07 15:31
hpjchobbes5-Jan-07 15:31 
AnswerRe: How to get a bitmap image from part of a larger bitmap? Pin
Luc Pattyn5-Jan-07 17:21
sitebuilderLuc Pattyn5-Jan-07 17:21 
Questionhow to check your sql for ANSI complaint Pin
WayneGretzky5-Jan-07 9:41
WayneGretzky5-Jan-07 9:41 
AnswerRe: how to check your sql for ANSI complaint Pin
Christian Graus5-Jan-07 9:48
protectorChristian Graus5-Jan-07 9:48 
Questionc++ from c# Pin
picazo5-Jan-07 8:42
picazo5-Jan-07 8:42 
Hi,

I have an unmanaged C++ class, and a managed c++ wrapper for the class. I then access the managed c++ from c# client. The whole thing compiles fine, but when I run the c# client, it crashes as soon as it hits the line where the managed c++ object is initialized. Here is the code that I am working with:

// C++ CODE

#include <windows.h>
#include <vcclr.h>
#using <System.dll>
using namespace System;


// from msdn
class UnManagedClass
{
public:
	LPCWSTR GetPropertyA() { return 0; }
	void MethodB ( LPCWSTR ) {}
};

public ref class AdapterNET
{
private:
	UnManagedClass * m_unman;

public:
	// allocate unmanaged object
	AdapterNET() : m_unman( new UnManagedClass ) {}

	// deallocate unmanaged object
	~AdapterNET() { delete m_unman; }

protected:
	// deallocated unmanaged object in finalizer in case the constructor is never called
	!AdapterNET() { delete m_unman; }

public:
	property String ^ get_PropertyA
	{
		String ^ get()
		{
			return gcnew  String( m_unman->GetPropertyA() );
		}
	}

	void MethodB( String ^ aString )
	{
		pin_ptr<const WCHAR> str = PtrToStringChars( aString );
		m_unman->MethodB( str );
	}
};


// C# CODE
using System;
using System.Collections.Generic;
using System.Text;

namespace TestingAdapterNET
{
	class AdapterNETDriver
	{
		static void Main( string[] args )
		{
			AdapterNET _adapterNET = new AdapterNET();  // <-- crashes here
			string propA = _adapterNET.get_PropertyA;
			_adapterNET.MethodB( propA );
		}
	}
}


Any ideas?

Thanks,

-----------------
Genaro

AnswerRe: c++ from c# Pin
Luc Pattyn5-Jan-07 8:50
sitebuilderLuc Pattyn5-Jan-07 8:50 
GeneralRe: c++ from c# Pin
picazo5-Jan-07 9:08
picazo5-Jan-07 9:08 
GeneralRe: c++ from c# Pin
Luc Pattyn5-Jan-07 9:32
sitebuilderLuc Pattyn5-Jan-07 9:32 
GeneralRe: c++ from c# Pin
picazo5-Jan-07 9:49
picazo5-Jan-07 9:49 
GeneralRe: c++ from c# Pin
Luc Pattyn5-Jan-07 10:13
sitebuilderLuc Pattyn5-Jan-07 10:13 
GeneralRe: c++ from c# Pin
Luc Pattyn5-Jan-07 10:36
sitebuilderLuc Pattyn5-Jan-07 10:36 
GeneralRe: c++ from c# Pin
Steve Hansen5-Jan-07 22:40
Steve Hansen5-Jan-07 22:40 
GeneralRe: c++ from c# Pin
Luc Pattyn6-Jan-07 3:49
sitebuilderLuc Pattyn6-Jan-07 3:49 
AnswerRe: c++ from c# Pin
Christian Graus5-Jan-07 9:46
protectorChristian Graus5-Jan-07 9:46 
QuestionTreeview and xml???????????? Pin
sajid.salim.khan5-Jan-07 8:41
sajid.salim.khan5-Jan-07 8:41 
AnswerRe: Treeview and xml???????????? Pin
Nader Elshehabi5-Jan-07 11:09
Nader Elshehabi5-Jan-07 11:09 
GeneralRe: Treeview and xml???????????? Pin
Stefan Troschuetz5-Jan-07 22:12
Stefan Troschuetz5-Jan-07 22:12 
GeneralRe: Treeview and xml???????????? Pin
Nader Elshehabi5-Jan-07 23:08
Nader Elshehabi5-Jan-07 23:08 
AnswerRe: Treeview and xml???????????? Pin
Larantz5-Jan-07 13:47
Larantz5-Jan-07 13:47 
AnswerRe: Treeview and xml???????????? Pin
Stefan Troschuetz5-Jan-07 22:14
Stefan Troschuetz5-Jan-07 22:14 
Questionhow do i Read an Excell file Pin
Iridania5-Jan-07 8:41
Iridania5-Jan-07 8:41 
AnswerRe: how do i Read an Excell file Pin
Christian Graus5-Jan-07 9:51
protectorChristian Graus5-Jan-07 9:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.