Click here to Skip to main content
15,914,071 members
Home / Discussions / C#
   

C#

 
GeneralRe: Question about music Pin
tom_dx3-Nov-04 12:17
tom_dx3-Nov-04 12:17 
GeneralNetwork synchronization of serialized files Pin
jeweladdict2-Nov-04 11:38
jeweladdict2-Nov-04 11:38 
GeneralHelp simple string passing :( Pin
BambooMoon2-Nov-04 10:18
BambooMoon2-Nov-04 10:18 
GeneralRe: Help simple string passing :( Pin
tom_dx2-Nov-04 11:57
tom_dx2-Nov-04 11:57 
GeneralRe: Help simple string passing :( Pin
BambooMoon2-Nov-04 12:16
BambooMoon2-Nov-04 12:16 
GeneralRe: Help simple string passing :( Pin
tom_dx2-Nov-04 12:20
tom_dx2-Nov-04 12:20 
GeneralRe: Help simple string passing :( Pin
BambooMoon2-Nov-04 12:58
BambooMoon2-Nov-04 12:58 
GeneralRe: Help simple string passing :( Pin
BambooMoon3-Nov-04 6:26
BambooMoon3-Nov-04 6:26 
I figured out how to do it, in case anyone is interested.

I wrote:
> The MC++ DLL has class Managed, where Managed::Managed() consists of:
> m_pUnmanaged = new CUnmanaged();
> and Managed::SetStringValue(String* strValue) consists of:
> m_pUnmanaged->SetStringValue(strValue);

That line "m_pUnmanaged->SetStringValue(strValue);" has to be replaced with:

IntPtr stringPointer = Marshal::StringToHGlobalAnsi(strValue);
m_pUnmanaged->SetStringValue(static_cast<char *="">(stringPointer.ToPointer()));
Marshal::FreeHGlobal(stringPointer);

That gets rid of the error about "object reference is not set to an instance of an object".

But it still leaves the C# program asserting when it closes. That is solved by changing the MC++ DLL to link statically with MFC, not dynamically. Why that would be required, I have no idea.

Finally, although I already knew this before I made my original post, it is required to change the MC++ DLL from its default settings to those outlined in http://support.microsoft.com/default.aspx?scid=kb;en-us;814472
(PRB: Linker Warnings When You Build Managed Extensions for C++ DLL Projects)
Roll eyes | :rolleyes:
GeneralInstrumentation Pin
mathon2-Nov-04 8:28
mathon2-Nov-04 8:28 
GeneralRe: Instrumentation Pin
kayhustle2-Nov-04 9:19
kayhustle2-Nov-04 9:19 
GeneralRe: Instrumentation Pin
mathon2-Nov-04 10:02
mathon2-Nov-04 10:02 
GeneralRe: Instrumentation Pin
Dave Kreskowiak3-Nov-04 3:35
mveDave Kreskowiak3-Nov-04 3:35 
GeneralRe: Instrumentation Pin
mathon3-Nov-04 6:35
mathon3-Nov-04 6:35 
GeneralRe: Instrumentation Pin
Dave Kreskowiak3-Nov-04 11:40
mveDave Kreskowiak3-Nov-04 11:40 
GeneralMSDN UDP Sample does not run Pin
win32wiz2-Nov-04 7:49
win32wiz2-Nov-04 7:49 
GeneralRe: MSDN UDP Sample does not run Pin
Charlie Williams2-Nov-04 8:32
Charlie Williams2-Nov-04 8:32 
QuestionClearing device with alpha? Pin
Jaran Nilsen2-Nov-04 6:48
Jaran Nilsen2-Nov-04 6:48 
QuestionHowto Instantiate a class of unknown type? Pin
Member 14185452-Nov-04 6:37
Member 14185452-Nov-04 6:37 
AnswerRe: Howto Instantiate a class of unknown type? Pin
Nick Parker2-Nov-04 8:00
protectorNick Parker2-Nov-04 8:00 
GeneralLine Break Pin
goatstudio2-Nov-04 5:58
goatstudio2-Nov-04 5:58 
GeneralRe: Line Break Pin
kayhustle2-Nov-04 10:26
kayhustle2-Nov-04 10:26 
GeneralListView CheckBoxes Pin
mrlou882-Nov-04 5:42
mrlou882-Nov-04 5:42 
GeneralRe: ListView CheckBoxes Pin
mrlou882-Nov-04 6:09
mrlou882-Nov-04 6:09 
GeneralPanel doubt Pin
ee990352-Nov-04 5:32
ee990352-Nov-04 5:32 
GeneralRe: Panel doubt Pin
Michael P Butler2-Nov-04 5:52
Michael P Butler2-Nov-04 5:52 

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.