Jump to content
  • Advertisement
Sign in to follow this  
dxFoo

Why is System::Net not in scope while using Managed C++?

This topic is 4589 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I was exploring my options using System::Net in my C++ program, and I noticed System::Net was nowhere to be found. How come? Was System::Net not part of the .NET framework? How can I take advantage of networking features then? Thanks in advanced.

Share this post


Link to post
Share on other sites
Advertisement
You need to add a reference to System.Net.dll. Right click on the References node and choose "Add Reference".

If you're using VS2002, you won't have a References node. You can instead put this in your source file (like an #include):

#using <System.Net.dll>

Share this post


Link to post
Share on other sites
Actually, parts of the System.Net namespace are in mscorlib.dll and System.dll. The documentation pages for the various types list which assembly they are located in.

Share this post


Link to post
Share on other sites
I get this error...

fatal error C1107: could not find assembly 'System.Net.dll': please specify the assembly search path using /AI or by setting the LIBPATH environment variable

Using VS 2005, I look in the add references window and System.Net isn't there.

Share this post


Link to post
Share on other sites
I got it. I removed the System.Net.dll and just used System.dll. The NET namespace is already contained inside. So, I guess now I ask what's the differences between mscorlib.dll and System.dll?

And... System::Uri::Uri(System::String ^)' : cannot convert parameter 1 from 'System::Uri ^' to 'System::String ^'

Wha?


System::Uri sample = gcnew System::Uri("http://www.google.com");

Console::WriteLine("Host: " + sample.Host);
Console::WriteLine("Port: " + sample.Port);
Console::WriteLine("Scheme: " + sample.Scheme);



Share this post


Link to post
Share on other sites
I haven't used managed C++ in 2005 or anything, so maybe they added some things ... but last time I checked:

"Host: " was not a string, and therefore does not support the + operator ...

I don't know wht the Uri line wouldn't be right.

Share this post


Link to post
Share on other sites
gcnew returns a pointer to an object on the managed heap. I think you mean:


System::Uri ^sample = gcnew System::Uri("http://www.google.com");


Magius

Share this post


Link to post
Share on other sites
Oh, that makes sense. It works now :) And Host would cast to a string here because of how Console::WriteLine() works. You could do sample->Host->ToString(), but it is redundent.

Thanks for the help.


Uri ^sample = gcnew Uri("http://www.google.com");

Console::WriteLine("Host: " + sample->Host);
Console::WriteLine("Port: " + sample->Port);
Console::WriteLine("Scheme: " + sample->Scheme);


Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!