Interface to C++ (unmanaged) DLL and std::string or std::wstring

H

Howie Meier

Hallo NG,

i can call functions from a native C++-dll wich uses "const char *" as
stringtype via P/Invoke without problems. Is there an easy way to call
functions that uses std::string or std:wstring in the function call ?

Has someone a tiny example how to access such a DLL with an
IJW-Interface ?


Thanx in advance,

Howie
 
W

Willy Denoyette [MVP]

| Hallo NG,
|
| i can call functions from a native C++-dll wich uses "const char *" as
| stringtype via P/Invoke without problems. Is there an easy way to call
| functions that uses std::string or std:wstring in the function call ?
|

You can't pass such kind of objects using PInvoke. PInvoke only deals with C
style functions and argument types.
| Has someone a tiny example how to access such a DLL with an
| IJW-Interface ?
|

IJW is a MC/C++ term and has nothing to do with C#, the only way to interop
with C/C++ is through PInvoke.

Willy.
 
H

Howie Meier

On Fri, 3 Nov 2006 10:16:54 +0100, "Willy Denoyette [MVP]"

Thanks Willy
| Has someone a tiny example how to access such a DLL with an
| IJW-Interface ?
|

IJW is a MC/C++ term and has nothing to do with C#, the only way to interop
with C/C++ is through PInvoke.
You are wrong. It means "It Just Works" and is the way to make a C++
DLL with managed and unmanaged Code together. The C# will only need to
access the C++ managed level.

Howie
 
W

Willy Denoyette [MVP]

| On Fri, 3 Nov 2006 10:16:54 +0100, "Willy Denoyette [MVP]"
|
| Thanks Willy
|
| >| Has someone a tiny example how to access such a DLL with an
| >| IJW-Interface ?
| >|
| >
| >IJW is a MC/C++ term and has nothing to do with C#, the only way to
interop
| >with C/C++ is through PInvoke.
| >
| You are wrong. It means "It Just Works" and is the way to make a C++
| DLL with managed and unmanaged Code together. The C# will only need to
| access the C++ managed level.


Sorry, but I'm right, C# doesn't have a notion of IJW, it's an "interop
layer" provided by the MC++ compiler to mixed mode C++ (/clr compiler flag)
it's not applicable to C# nor is it part of the CLR. Sure you can access
managed C++ from C#, both use the same object model, but you can't use C# to
access unmanaged C++ in a IJW fashion like MC++ is doing. Note also that the
term IJW is no longer used for C++/CLI, now it's called "C++ interop".

Willy.
 
H

Howie Meier

Sorry, but I'm right, C# doesn't have a notion of IJW, it's an "interop
layer" provided by the MC++ compiler to mixed mode C++ (/clr compiler flag)
it's not applicable to C# nor is it part of the CLR. Sure you can access
managed C++ from C#, both use the same object model, but you can't use C# to
access unmanaged C++ in a IJW fashion like MC++ is doing. Note also that the
term IJW is no longer used for C++/CLI, now it's called "C++ interop".
Excuse me Willy, you are right, i have read MFC not MC.

Thanks.

Howie
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top