Memory problems when hosting ASP.NET on Windows 2003

by Sander Gerz April 26, 2007 07:43

Hoster Poster made me aware of an interesting KB article that describes the issue of failures when hosting ASP.NET on Windows 2003. Simple reading the title really makes you wonder:

“You may receive an error message, or the computer may stop responding, when you host Web applications that use ASP.NET on a computer that is running Windows Server 2003“

Say what? If I host ASP.NET on Windows Server 2003 I may receive an error or the machine may stop responding altogether? Okay, the article itself explains the conditions under which this may occur. But it doesn't make me happy (as we're doing ASP.NET hosting too).

Currently rated 1.5 by 4 people

  • Currently 1.5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Trouble with threads and cultures

by Sander Gerz April 11, 2007 14:19

Here's something that bit me today. A few days ago, a Windows Service I built was redeployed to another machine. Most operations went on just fine, but some didn't. And as always: 'it worked on my machine'. As it had also worked in testing and on the previous production server. After some digging, we found that the regional settings for the service account on this machine were not what they were on the other servers. Yes, I know, don't depend on regional settings, but there was some legacy code (hah..it's not my fault) and it had never created issues before.

So, easy enough, we set the thread for the service to the required culture, like so:

System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("nl-NL");

Unfortunately, it didn't have the desired effect. Nothing changed. As it turns out, you have to set the culture on every thread running. See the sample below:

using System;

using System.Globalization;

using System.Threading;

 

namespace RegionalTime

{

    class ClassDemo

    {

        public static void TimeNow()

        {

            Console.WriteLine("Date setting: {0} ({1})",

                DateTime.Now.ToLongDateString(),

                Thread.CurrentThread.CurrentCulture.DisplayName);

        }

 

        public delegate void TimeNowDelegate();

 

        [STAThread]

        static void Main(string[] args)

        {

            // Look at current regional settings

            TimeNow();

 

            // Switch to French

            Thread.CurrentThread.CurrentCulture = new CultureInfo("fr-FR");

            TimeNow();

 

            // Switch to US

            Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");

            TimeNow();

 

            // Now through a delegate on a different thread.

            TimeNowDelegate methodDelegate = new TimeNowDelegate(TimeNow);

 

            IAsyncResult result = methodDelegate.BeginInvoke(null, null);

 

            while (!result.IsCompleted)

            {

                Thread.Sleep(500);

            }

 

        }

    }

}

As you will see, from running this code, the call through the delegate uses the regional settings from the active user.

Date setting: woensdag 11 april 2007 (Dutch (Netherlands))
Date setting: mercredi 11 avril 2007 (French (France))
Date setting: Wednesday, April 11, 2007 (English (United States))
Date setting: woensdag 11 april 2007 (Dutch (Netherlands))
Press any key to continue . . .

There seems to be no way to specify one culture for the entire AppDomain (note: I'm not talking about ASP.NET here, this was a multithreaded Windows Service). If any thinks or better yet, knows, that this is possible, let me know. I am always eager to learn.

 

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

.NET

DevTips.NET renewed

by Sander Gerz April 10, 2007 09:23

It's taken quite some time, but I've finally put the new DevTips.NET website online. The old site was really... old. The codebase was from 2001 when I learned to code in C# myself. You can imagine it didn't incorporate best practices, since there were few practices to begin with.

So a rewrite was quite necessary. Now, I could have used DotNetNuke, or CommunityServer or any other project to base the new site on but where the fun in that ;-)

The entire code was written by me, but I did use TechTalk's Genome (sorry, Frans) as the O/R mapper which saved me a lot of time.

One of the decisions I made was to remove the forum. For one, the forum was not very active and this would prove dissappointing for people asking questions. Secondly, there are a number of Dutch forums already available (like the ones on www.dotned.nl, www.sdn.nl, and www.vbcentral.nl). Improvements have been made to the layout (most obvious), the commenting and rating system. Also, it's easier to edit content and publish news stories with more body than previously.

If you would like to add content to the site, e.g. news, codesnippets, articles or otherwise, please register an account. You can add and manage codesnippets immediately. If you want to publish news or articles, drop me a line.

If you spot any errors, please let me know.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Congratulations! We are pleased to present you with the 2007 Microsoft® MVP Award!

by Sander Gerz April 01, 2007 10:46

This just in: “The Microsoft MVP Award is our way of saying thank you and to honor and support the significant contributions you make to communities worldwide. As a recipient of Microsoft’s Most Valuable Professional award, you join an elite group of technical community leaders from around the world who foster the free and objective exchange of knowledge by actively sharing your real world expertise with users and Microsoft.  Microsoft salutes all MVPs for promoting the spirit of community and enhancing people’s lives and the industry’s success everyday.  To learn more about the MVP Program, visit: www.microsoft.com/mvp.”

What can I say? I've been active in the community this past year (mmm... not so much on this blog, I have to work on that), so I was hoping to get my MVP status renewed, but you never know for sure until you get this e-mail. I think it's also an encouragement to continue my efforts.

In fact, at this very moment I'm planning the sessions for our first Dutch .NET CodeCamp: http://www.code-camp.nl/. A joint effort of SDN, VBCentral and DotNed. It looks like we've got more session proposals (25) than we can accomodate (+/- 20), so it's going to be a packed day. If you haven't signed up, please hurry, because there's a limit of 120 attendees. Given that the event won't draw hundreds of people means you can more easily interact with your peers, and with the speakers. Subjects will range from: WPF, LINQ, XNA, WF, and many other MLA's (multi-letter-acronyms). However, it will not all be about great “new stuff”. We'll also cover topics that address issues we're having today. How about: COM Interop, ASP.NET Ajax, Designing Windows Controls. I'll do a session (if I can fit it in) on Visual C# 2005 tips and tricks. Although upon request, we dive into the new 'Orcas' release as well.

Anyway, I'm grateful to be nominated MVP again and hope to see you on May 12th.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Powered by BlogEngine.NET 1.4.5.0
Theme by Mads Kristensen | Modified by Mooglegiant