1

I have some managed C# code which is accessed on a thread from C++ through COM.

When I make an HttpWebRequest in my C# code it initially works, if I deactivate some of the code on the C++ side. However, when I reactivate all the C++ code, then my C# HttpWebRequests start failing with the error: "Either the application has not called WSAStartup, or WSAStartup failed". Which is bizarre because WSAStartup never needs calling from C#, I imagine it's hidden in the C# wrapper around the TCP stack. Does anyone have an idea what the real error could be?

EDIT: In my C++ code I have one direct call to WSAStartup() so I removed it, and now the error message has changed to "System.Net.Sockets.SocketException: An operation was attempted on something that is not a socket".

MD XF
  • 7,860
  • 7
  • 40
  • 71
evilfred
  • 2,314
  • 4
  • 29
  • 44
  • And what does that de-/re-activated code do? – H H Sep 16 '10 at 18:32
  • I wish I could tell you. Nothing fancy. A bunch of accompanying DLLs. Link in stuff like tapi32.lib setupapi.lib shlwapi.lib. – evilfred Sep 16 '10 at 18:44
  • Can you show the code? Also, can you get a system.net tracelog for your app? USe this link http://ferozedaud.blogspot.com/2009/08/tracing-with-systemnet.html to create a .config file with the same name as your app executable (appname.exe.config) and put the config file in the same directory as the executable. THis should end up creating a system.net logfile. – feroze Sep 20 '10 at 04:32
  • Does your C++ code call `WSACleanup()`? – Sergey Vyacheslavovich Brunov Feb 18 '12 at 19:07

0 Answers0