How do I wrap the following c++ Struct in c#??? 
Author Message
 How do I wrap the following c++ Struct in c#???

Hi Sirs
I'm not that familiar with c++ and I have to make a call from C#  to an
unmanaged function which expects the struct below as a parameter.

How do I make the managed struct in c#?

Regards Morten

typedef void *MRBSESSION;

typedef void *MRBPLUGINCONN;

typedef long (*MRBNOTIFY)(long msg, const char *msgtxt, const void
*userParam);

typedef long (*MRBPROXYAUTH)(const void *userParam, char *auth);

typedef long (*MRBHTTPAUTH)(const void *userParam, const char *scheme, const
char *realm, char *auth);

typedef long (*MRBFILEFILTER)(const void *userParam, const char *base, const
char *node);

/*

* Update information supplied to mrbOpen.

*/

typedef struct {

const char *baseDir;

MRBNOTIFY notify;

MRBPROXYAUTH proxyAuth;

MRBHTTPAUTH httpAuth;

const char *httpUserAgent;

const void *userParam;

long flags;

const char *url;

long timeout;

Quote:
} MRBSESSIONINFO;



Sun, 21 Nov 2004 15:08:45 GMT  
 How do I wrap the following c++ Struct in c#???
Please only use
  microsoft.public.dotnet.framework.interop
for this Interop question!

If I understand your code, the struct contains
a callback fn 'MRBNOTIFY' which is executed
from the C++ side defined by
   typedef long (*MRBNOTIFY)(long msg, const char *msgtxt, const void *userParam);

The problem is, this marks an 'cdecl' calling convention.
Please verify if this is true, or if you can change the C++ src
to the CALLBACK (stdcall) convention.

If you can't change the C++ side, this will not work
directly in C#, so read this workarounds:
   http://groups.google.com/groups?selm=ew6mLkV6BHA.1932%40tkmsftngp03

--
  NETMaster  (Thomas Scheidegger)
  http://www.cetus-links.org/oo_csharp.html

Quote:

> I'm not that familiar with c++ and I have to make a call from C#  to an
> unmanaged function which expects the struct below as a parameter.
> How do I make the managed struct in c#?
> typedef long (*MRBNOTIFY)(long msg, const char *msgtxt, const void *userParam);
> typedef struct {
> const char *baseDir;
> MRBNOTIFY notify;



Sun, 21 Nov 2004 16:39:36 GMT  
 How do I wrap the following c++ Struct in c#???
microsoft.public.dotnet.framework.interop will be a better place for this
question.

The following link might have the information you need.
http://msdn.microsoft.com/library/en-us/csref/html/vcwlkPlatformInvok...
al.asp?frame=true

This posting is provided "AS IS" with no warranties, and confers no rights.
Got .Net?  http://www.gotdotnet.com



Mon, 22 Nov 2004 00:22:26 GMT  
 How do I wrap the following c++ Struct in c#???



Quote:
> microsoft.public.dotnet.framework.interop will be a better place for this
> question.

I doesn't think so.
You get seldom an answer in this group.  :-(

Quote:

> The following link might have the information you need.

http://msdn.microsoft.com/library/en-us/csref/html/vcwlkPlatformInvok...

Quote:
> al.asp?frame=true

p


Mon, 22 Nov 2004 16:06:55 GMT  
 How do I wrap the following c++ Struct in c#???

Quote:
> You get seldom an answer in this group.  :-(

This is not true ... you have to know interop problems
often are VERY specific to some 3rd party code!

Many of the posted interop problems can only
be reproduced by writing a small sample,
or even by downloading 3rd party components!
So it takes time as you can't simply do an MSDN-help search.

Interop is a complex task, but some people try
to do this without any experience (e.g. in COM) ...

And unfortunately, (AFAIK) it isn't a managed newsgroup
for MSDN subscribers...

--
  NETMaster  (Thomas Scheidegger)
  http://www.cetus-links.org/oo_csharp.html

Quote:



> > microsoft.public.dotnet.framework.interop will be a better place for this
> > question.
> I doesn't think so.
> You get seldom an answer in this group.  :-(



Mon, 22 Nov 2004 17:18:52 GMT  
 How do I wrap the following c++ Struct in c#???
I would suggest to try the specialty group first. If there no response,
post it in this group with the comment "repost due to no response from
<name of newsgroup>". We will then get the right folks involve.

This posting is provided "AS IS" with no warranties, and confers no rights.
Got .Net?  http://www.gotdotnet.com



Mon, 22 Nov 2004 22:55:40 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. How To: Managed C++ class calling/wrapping C functions and structs

2. How do I wrap the following c++ Struct in c#???

3. error: typdef name cannot follow class/struct/union?

4. Need DllImport expert to convert c++ to c# - same struct pointer in struct

5. c# struct vs c++ struct

6. Wrapped CTreeCtrl in Wrapped CTreeView?

7. Mixing C/C++ FORTRAN follow-up

8. Wrapping MCF classes in Managed c++ library

9. Creating verifiable dotnet assembly wrapping unmanaged C++ classes

10. Help me!! wrap unmanaged class with managed c++

11. Why wrapping unmanaged C++ singletons can be dangerous

12. How To: Wrapping a C library in Managed C++

 

 
Powered by phpBB® Forum Software