Console.ReadKey .NET 4.5 changes may deadlock your system

Wednesday, September 12, 2012

I’ve hit a weird issue today. We have a service that we run both as Windows service and from console. A specific use case seemed to cause our system to hang, but only when running from console. Also, I was sure this didn’t happen before I upgraded my machine to .NET 4.5. The service initialization code looks something like this: serviceHost.Open();   while (Console.ReadKey().Key != ConsoleKey.Q) { Console.WriteLine("Press Q to exit"); ...
2 comments

What’s Trace Got To Do With Culture?

Saturday, March 29, 2008

I really don't know the answer to that question, but we've hit the strangest issue. The following code runs well when <trace enabled="true"> is set on web.config, but throws FormatException when it's set to false. DateTime.Parse(DateTime.Now.ToString()); We're thinking that somehow trace affects the system's culture, causing the code work. But it still doesn't make any sense to us. Looking in debug, it seems that DateTime.Now.ToString returns "DD" instead of the day, altought the current culture is "en-US". Can you make anything of it? Oh, and I should mention, this happens only on Windows 2000 Professional. When...
no comments

Upgrading to .NET 2.0? PowerCollections to your Aid.

Saturday, September 1, 2007

The .NET 2.0 framework has been here a while, but if you're like my team, you're still using a lot of code that you wrote back at the .NET 1.1 days. It's likely that many of these methods are using non-generic collections. This poses an annoying issue. Check out this method: public IList GetAllUsers(IList userCodes) { IList list = new ArrayList(); //Add the users here... //... return list; ...
no comments

IsolatedStorage to the Rescue

Saturday, August 18, 2007

Up until recently I've been totally unaware to an extremely useful .NET feature known as IsolatedStorage. It goes like this. Let's say you have a client application, right? And that application needs to store some data, right? Some user preferences maybe. Thing is, trying to simply write that data into a file can be a problem. Your application might not have the permissions needed to write to the file system. In fact, if we're talking about a browser application, that's a very likely situation. Here IsolatedStorage comes to our rescue. It allows you to write application or assembly specific...
no comments