|
I am using Visual Studio 7.0 to begin to learn Socket programming. Unfortunatley the System.Net and System.Net.Sockets namespaces do not exist. When I compile my project I get the following error.
"The type or namespace name 'Net' does not exist in the class or namespace 'System' (are you missing an assembly reference?)"
Now Ive been looking on the net for a solutions to this problem and every one says to add a refrence to the System.Net.dll on my machine. Ive looked and looked but the System.Net.dll does not exist. Is there anywhere I could download it?
Thanks
|
|
|
|
|
Have you made sure you installed the .NET framework.
I had this problem once and I had to uninstall the Framework and reinstall and everything worked fine.
|
|
|
|
|
You're right, it doesn't exist; its part of System.dll which declares quite a few other types. Ensure that it is properly referenced in your project (it is by default but you could have accidentally removed it).
James
Simplicity Rules!
|
|
|
|
|
Just to make sure I added a refrence to every .NET dll to the project including System and there is still no System.Net namespace.
Is there a place where I could download it?
Thanks
|
|
|
|
|
System.dll is where the System.Net namespace is declared (I checked with Anakrino) so that means you have a spelling error, or your .NET install is corrupt
I don't think there is any place that has that single dll online, my System.dll is 1.10MB and was last modified January 5th, 2002; check yours to make sure it is the same. You can find it in %WINDIR%\Microsoft.NET\Framework\%DOTNET_VERSION%\
HTH,
James
Simplicity Rules!
|
|
|
|
|
Try manually adding the reference to the system.dll through the Add Reference menu item in the solution explorer (rt click on the reference tab or thru project menu). I assumed you had vs.net installation.
I ran into same issue couple of days back, it worked for me.
Hope this helps
Kannan
I am not here to accommodate the requirements of mass hysteria.
|
|
|
|
|
Hi All,
I thought I had finally figured out cookies and have now run into another problem.
I have 2 pages which both add data to a cookie as follows
**********Page 1**********
HttpContext.Current.Response.Cookies["MyCookie"]["Session"]= Session.SessionID;
HttpContext.Current.Response.Cookies["MyCookie"]["MyName"] = "Gavin";
HttpContext.Current.Response.Cookies["MyCookie"]["MyDrink"] = "Beer";
**********Page 2**********
HttpContext.Current.Response.Cookies["MyCookie"]["MyFood"]= "Pizza";
HttpContext.Current.Response.Cookies["MyCookie"]["MyTeam"] = "Liverpool";
**************************
After Page 1 as I enter Page 2 my 3 Cookie Keys (Session, MyName & MyDrink) are all fine, but as I try and add the 2 new Keys my cookie loses the first 3?
I hope everyone understood that one
Can someone explain why this is and how do I stop it.
I am looking at saving about 100 different things in this cookie so I don't really want to rewrite all the keys on every page.
Thanks,
Gavin
|
|
|
|
|
It appears you're right, the cookies are reset after each round trip; but the more I thought about it the more it made sense. A cookie is just text that is passed back and forth between the server and the client. And if memory serves correctly to not pass the cookie back to the client tells the client to delete the cookie.
One thing you can do to preserve the cookies is to loop through the list and re-add the cookie to the response.
for( int i = 0; i < Request.Cookies.Count; i++ )<br />
{<br />
Response.Cookies.Add(Request.Cookies[i]);<br />
}
This is something I think ASP did for you, but I don't remember off hand.
Now, to save you from bickering from your users; PLEASE don't use cookies to store that much data Its okay to store a few bits, but you are limited in your cookie space by most browsers; and that is more traffic that goes to the server and back to the client.
ASP.NET's session object is now webfarm friendly with use of either an out-of-proc server or using SQL Server as the session state holder.
With that said you're going to need a way to store your data, if you can't use a database to store the data then at least put all your data in a memory stream (or some other form so it is one contigous block), compress it, then base64 encode it and store that in the cookie. The space you save will make your users and your provider happy
Good Luck,
James
Simplicity Rules!
|
|
|
|
|
Okay in original ASp I was told to never store so much data in a Session Object and to either use Cookies or a Database.
Now I'm being told not to use Cookies for this much data?
You just can't win, at least it makes sense now though, I will use my SQL database instead.
Cheers,
Gavin
PS: Thanks for the help
|
|
|
|
|
Original ASP had the problem where the session object wasn't webfarm friendly, so you had major scalability issues involved. With ASP.NET you can use a SQL Server Database to store the session data or an out-of-proc server (exe) on the network to host it; so it is webfarm friendly and thus scales pretty well.
Now of course session data is going to take up RAM on the server the session is stored on; but how much data is really being taken up per session? Probably not enough to make it matter.
James
Simplicity Rules!
|
|
|
|
|
Hi to all...
Does anybody knows how to center the child window (Main Form View) in SDI application??? I've tried tried and tried, but still cannot get the child form to be centralized.
Please help or give a little advice / pointers how to get round this. Thanks.
Rdgs, Ben
|
|
|
|
|
You can always position it manually; child.Location = new Point((ClientArea.Width - child.Bounds.Width) / 2, (ClientArea.Height - child.Bounds.Height) / 2);
James
Simplicity Rules!
|
|
|
|
|
Is there a colour picker in C# to choose from the Color enumeration by color or name ? If not, I thought I might write one, but I'd hate to do it and find out there's one as standard....
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
|
|
|
|
|
Just the good old Color Dialog is truly documented.
I did notice a number of color pickers in the C#/Controls section here on Code Project.
Regards
|
|
|
|
|
Hi everyone,
i have an ArrayList where I have some object from my class Cxxxx. each object has one ArrayList where i would have object of my class Cxx2, but i need that this second ArrayList must be create later, only when i need, so i need to know if exist any way to access some object of Array List and modify it content.
Thanks in advance.
Salamanca 2002 Capital Cultural Europea, Visitala
|
|
|
|
|
What?
Did you try the indexer?
i.e.
MyObject o = (MyObject) myArray[i];
.
.
.
Regards
|
|
|
|
|
In C++, I would declare my data values as private members with public get/set methods. I can do the same thing in C#, but I can also use properties. Any guideance on when to use one vs the other? Is there any performance/size difference? Thanks
Chris Hafey
|
|
|
|
|
Properties basically accomplish the same thing. Each propert should have an accompanying private field for the actual value. The only advantage is that you can do this :-
abc.val = whatever;
Nish
The rumours that I am an AI bot are absolutely false. These rumours have been propogated by *them* to focus all the attention on to me, while *their* bots take over the planet. Thank y%%%% Divide by zero. Cannot proceed. Abort(y/y)?
|
|
|
|
|
You should use properties when you are dealing with storing the data in a private variable.
You should use Get/Set methods when that data is NOT being stored cannot be accessed as quickly as a "return myPrivateData;". Some applications of this type would be retreive the customer name from the database; return all the prcoesses running on the system, etc...
The line is a fine one and its quite elastic so just go with what feels right
James
Simplicity Rules!
|
|
|
|
|
Stick with Properties when appropriate.
The Property Grid likes them, the debugger likes them, and Serialization likes them.
Go with the flow, it will make your life easier...
Regards
|
|
|
|
|
Hi All,
Quick question here, I need to check to see if a cookie exists when someone enters 1 of my pages.
This is an intranet so I know that everyone accepts cookies but is there way to see if a certain cookie exists?
Thanks,
Gavin
|
|
|
|
|
Check the cookie for null
James
Simplicity Rules!
|
|
|
|
|
Tried that,
for some reason the page falls over if I try the following
if (HttpContext.Current.Request.Cookies["NewOutbreak"]["Test"] == "")
{
//Do Something amazing
}
else
{
Go home
}
I get an error saying something like cannot check for null as it doesn't exist.??
|
|
|
|
|
I wonder if you are getting the error from the "NewOutbreak" cookie not existing and then trying to access it.
Give this a shot...
<br />
Request r = HttpContext.Current.Request;<br />
if(r.Cookies["NewOutbreak"] == null)<br />
{<br />
}<br />
else if( r.Cookies["NewOutbreak"]["Test"] == null)<br />
{<br />
}<br />
else<br />
{<br />
}
I'm still working out your issue at the top
James
Simplicity Rules!
|
|
|
|
|
werkin
I see the logic, you have to check to see if the Cookie exists before checking to see if the cookies key exists or has any data...
Seems to be 100% Thanks
|
|
|
|