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

Started by
7 comments, last by dxFoo 18 years, 4 months ago
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.
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>
--AnkhSVN - A Visual Studio .NET Addin for the Subversion version control system.[Project site] [IRC channel] [Blog]
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.
--AnkhSVN - A Visual Studio .NET Addin for the Subversion version control system.[Project site] [IRC channel] [Blog]
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.
Still curious about this...
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);


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.
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
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);

This topic is closed to new replies.

Advertisement