Why is System::Net not in scope while using Managed C++?
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.
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>
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>
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.
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.
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.
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?
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.
"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:
Magius
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.
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
Popular Topics
Advertisement