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 / Languages / Managed C++ / March 2006

Tip: Looking for answers? Try searching our database.

MC++... unable to compile my code correctly :-(

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Chris - 27 Mar 2006 10:34 GMT
I m new to MC++ and interoperability and I try to find a bug since a long
time without succes, maybe you can help me ?

(I have a sample project if you want, you can contact me at
cdemez2@hotmail.com too)

I describe the problem:

I have 2 MS VC2003 projects... and have difference between both. The first
one is a MC++ project I have create, the second is the original C++ library
(that works fine!)

1 - Here is my managed class :
----------------------------------------------
public __gc class UFOzSocket
{
private:
  addrinfo _hints;
public:
  UFOzSocket(AddressFamily addressFamily, SocketType socketType);
  ~UFOzSocket();
  void Connect(EndPoint * remoteEP);
protected:
  UFOzSocket();
private:
  UDTSOCKET _internalSocket;
};

During debugging, when I see this structure, it is like this :

Structure in the first application, see by the debugger (Bad fields order):
-----------------------------------------------------------------------------
- _hints : addrinfo
+ ai_addr             : 0x00000000 sockaddr*
+ ai_addrlen         : 0 unsigned __int32
+ ai_canonname   : 0x00000000 char*
+ ai_family            :2 __int32
+ ai_flags              :1 __int32
+ ai_next               : 0x00000000 addrinfo*
+ ai_protocol          : 0 __int32
+ ai_socktype        : 1 __int32

Structure in the second application, see by the debugger (Good fields order):
----------------------------------------------------------------------------------
- hints {ai_flags=1 ai_family=2 ai_socktype=1 ...} addrinfo
+ ai_flags            : 1 int
+ ai_family          : 2 int
+ ai_socktype      : 1 int
+ ai_protocol        : 0 int
+ ai_addrlen         : 0 unsigned int
+ ai_canonname   : 0x00000000 <Bad Ptr> char *
+ ai_addr             : 0x00000000 {sa_family=??? sa_data=0x00000002 <Bad
Ptr> } sockaddr *
+ ai_next             : 0x00000000 {ai_flags=??? ai_family=???
ai_socktype=??? ...} addrinfo *

So, how can I change this to force the first application to have the same
behavior ?

Thanks for your help

Chris
Jochen Kalmbach [MVP] - 27 Mar 2006 10:50 GMT
Hi Chris!

>    UDTSOCKET _internalSocket;
>
> During debugging, when I see this structure, it is like this :

How is this structure defined?
You must use the "StructLayoutAttribute" attribute if you want to deal
with "offsets"...
See:
http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemRuntimeInteropServ
icesStructLayoutAttributeClassTopic.asp


Greetings
  Jochen
Chris - 27 Mar 2006 11:01 GMT
Thanks

but the problem is on the structure "addrinfo" defined like this :

typedef struct addrinfo
{
   int                 ai_flags;       // AI_PASSIVE, AI_CANONNAME,
AI_NUMERICHOST
   int                 ai_family;      // PF_xxx
   int                 ai_socktype;    // SOCK_xxx
   int                 ai_protocol;    // 0 or IPPROTO_xxx for IPv4 and IPv6
   size_t              ai_addrlen;     // Length of ai_addr
   char *              ai_canonname;   // Canonical name for nodename
   struct sockaddr *   ai_addr;        // Binary address
   struct addrinfo *   ai_next;        // Next structure in linked list
}
ADDRINFOA, *PADDRINFOA;

in the file "ws2tcpip.h"

and not in one of my files :-( ... so I cannot change it !

It is the problem !!
Chris - 27 Mar 2006 12:26 GMT
Jochen...

I have a sample project... in a ZIP that is ready, if you want to see to
problem...

It is simple, surely for you (I have see your web site about interop)... but
for me, it sounds complex ( I work on it since 2 week without success :-( )

Thanks for your help

> Hi Chris!
>
[quoted text clipped - 10 lines]
> Greetings
>    Jochen
Jochen Kalmbach [MVP] - 27 Mar 2006 12:52 GMT
Hi Chris!

> I have a sample project... in a ZIP that is ready, if you want to see to
> problem...

You can mail it to me:

jochen addddd kalmbachnet dottttt de

Greetings
  Jochen
Chris - 27 Mar 2006 14:40 GMT
Hi Jochen,

I have send you an email

Thanks for your help

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.