Jack is Here, asp.net findings

As a software engineer, I focus on .NET, especially asp.net, C#, WCF and so on, and I am also very interested in Search Engine Optimization.

Entries for January, 2011

How Windows Firewall affects the UPnP framework in Windows XP Service Pack 2

Symptoms
This article describes how Windows Firewall affects the Microsoft Windows UPnP framework in Microsoft Windows XP Service Pack 2 (SP2). This article also describes the changes that have been made in Windows XP SP2 to minimize these effects.
Note This article is intended for technical users and device manufacturers who are familiar with the UPnP architecture and protocols.
Article ContentsINTRODUCTIONMORE INFORMATIONBackgroundEffects of blocked UPnP portsWindows Firewall enhancements for the UPnP frameworkInstalling and removing UPnP UI componentsManually enable the Windows Firewall exception for the UPnP frameworkUPnP device and control point vendorsAdditional information
Resolution
By default, Windows Firewall is turned on when you install Windows XP SP2. Windows Firewall may have the following effects on the Windows UPnP framework: The UPnP framework may not be able to discover networked UPnP devices.The UPnP framework may not be able to control networked UPnP devices or to send events to and receive events from networked devices.UPnP control points may not be able to discover devices that are hosted on the Windows XP SP2-based computer.

How to catch exceptions in Visual C#

Symptoms
Catching and dealing with exceptions is a standard programming task. This article demonstrates how to use a try-catch-finally block to catch an exception. A try-catch-finally block is a “wrapper” that you put around any code where the possibility of an exception exists.
A try-catch-finally block consists of the following sections: Any code that may throw an exception is placed inside the try block.If an exception is thrown, the catch block is entered, and the program can perform the appropriate operation to recover or alert the user.The code in the finally block is always executed and can perform cleanup after an exception has occurred. The finally block is optional.
Requirements The following list outlines the recommended hardware, software, network infrastructure, and service packs that are required: Microsoft Windows 2000 Professional, Windows 2000 Server, Windows 2000 Advanced Server, or Windows NT 4.0 ServerMicrosoft Visual C# .NET or Microsoft Visual C# 2005
How to Catch Exceptions in Visual C# Create a new Console Application in Visual C#.
Note In Visual C# 2005,Program.cs is created by default instead of Class1.cs. Replace all of the code in the Class1 code window with the following sample code. The code declares and initializes three variables, wherein the initialization of “k” causes an error.

// This code generates an exception.using System;namespace ExceptionApp{class Class1{ static void Main() {Console.WriteLine(“We’re going to divide 10 by 0 and see what happens…”) ;Console.WriteLine() ; int i = 10 ;int j = 0 ;int k = i/j ; // Error on this line. }}} Press F5. You receive a System.DivideByZeroException exception.Wrap a try-catch statement around your code to capture the error. The following code catches all errors that are thrown in the code and displays a generic error message. Replace the code in the Class1 code window with the following:

// This code shows how to catch an exception.using System;namespace ExceptionApp{class Class1{ static void Main() {try{Console.WriteLine(“We’re going to divide 10 by 0 and see what happens…”) ;Console.WriteLine() ; int i = 10 ;int j = 0 ;int k = i/j ; // Error on this line.}catch{Console.WriteLine(“An error occurred.”);} }}} Press CTRL+F5 to run the application. Note that the error message from the catch block is displayed, rather than the system exception message.If some cleanup or post-processing needs to be done regardless of an error, use the finally part of the try-catch-finally statement. Code in the finally part of the statement is always executed, regardless of an exception. The following code displays “This statement is always printed” in the console, even if no error occurred. Replace the code in the Class1 code window with the following:

// This code shows how to catch an exception.using System;namespace ExceptionApp{class Class1{ static void Main() {try{Console.WriteLine(“We’re going to divide 10 by 0 and see what happens…”) ;Console.WriteLine() ; int i = 10 ;int j = 0 ;int k = i/j ; // Error on this line.}catch{Console.WriteLine(“An error occurred.”);}finally//This section is performed regardless of the above processing.{Console.WriteLine();Console.WriteLine(“This statement is always printed”);} }}} Press CTRL+F5 to run the project.You can use the exception object with the catch statement to retrieve details about the exception. An exception has a number of properties that can help you identify the source or even stack information about an exception. This information can be very useful for tracking down the original cause of the exception or providing a better explanation of its source. The following sample catches an exception and gives a specific error message. As before, you can replace the code in the Class1 code window with the following code:

// This code shows how to catch an exception.using System;namespace ExceptionApp{class Class1{ static void Main() {try{Console.WriteLine(“We’re going to divide 10 by 0 and see what happens…”) ;Console.WriteLine() ; int i = 10 ;int j = 0 ;int k = i/j ; // Error on this line.}catch(Exception e){Console.WriteLine(“An error occurred.”);Console.WriteLine(e.ToString());}finally//This section is performed regardless of the above processing.{Console.WriteLine();Console.WriteLine(“This statement is always printed”);} }}} The following code sample demonstrates how to obtain extended error information. This sample provides the message, the source of the error, and the stack trace:

// This code shows how to catch an exception.using System;namespace ExceptionApp{class Class1{ static void Main() {try{Console.WriteLine(“We’re going to divide 10 by 0 and see what happens…”) ;Console.WriteLine() ; int i = 10 ;int j = 0 ;int k = i/j ; // Error on this line. Control jumps to the catch block.}//Perform code that deals with the exception or inform the user what occurred.catch(Exception e){Console.WriteLine(“The following error occurred:”);Console.WriteLine( e.Message );// Print the error message.Console.WriteLine( e.Source );// Name of application or object that caused the error.Console.WriteLine( e.StackTrace ); //String that contains the stack trace for this exception.}finally//This section is performed regardless of the above processing.{Console.WriteLine();Console.WriteLine(“This statement is always printed”);} }}} Until this point, you have dealt with the particular case of a non-specific exception. However, if you know in advance what kind of exception is going to occur, you can catch the anticipated exception and process it accordingly. You can then use multiple catch blocks to catch all other exceptions and deal with them as well. The following sample demonstrates this:

// This code shows how to catch an exception.using System;using System.IO;using System.Security;namespace ExceptionApp{class Class1{ static void Main() { try { File.Create(“c:\\temp\\testapp.txt”);//can fail for number of reasons } // This error may occur if the temp folder does not exist. catch(IOException ioe) { Console.WriteLine(“An IO error ocurred. The c:\\temp folder does not exist”); } // You do not have the appropriate permission to take this action. catch(SecurityException se) { Console.WriteLine(“You don’t have the security permissions to take this action!”); } // Catch all exceptions. catch(Exception e) { Console.WriteLine(e.ToString()); } }}} Because computer configurations may be different, the sample in this step may or may not throw an exception. If you want to force an IO exception, change the file path to a folder that does not exist on your computer.

Halo Combat Evolved: Error Message: Cannot Allocate Required Memory

Symptoms
When you start Microsoft Halo: Combat Evolved you may receive an error message that is similar to the following:

Cannot allocate required memory. Some application has loaded where Halo wants to be located. The title of this error message varies depending on the program that is blocking Halo from loading. The title is the path of the program file that must be unloaded.
If you try to run Microsoft Halo: Combat Envolved you may receive a dialog box that states Gathering Exception data. After the dialog box disappears, you receive the following error message:

Halo executable has encountered a problem and needs to close. We are sorry for the inconvenience.If you click Click here, a dialog box appears. It contains the following information about the error:

AppName: halo.exe AppVer: 1.0.2.581 ModName: halo.exe ModVer: 1.0.2.581Offset: 00044b11AppName: halo.exe AppVer: 1.0.0564ModName: halo.exe ModVer: 1.0.0.564Offset: 0005aa82
Resolution
To resolve this issue, use the following methods in the order that they appear.
Note Because there are several versions of Microsoft Windows, the following steps may be different on your computer. If they are, see your product documentation to complete these steps.
Method 1: Restart your computer by using a clean boot procedure When you start Microsoft Windows, typically there are a number of programs that start automatically and run in the background that may interfere with the game. These programs may include antivirus and system utility programs. When you perform a clean boot, you prevent these programs from starting automatically.
You must be logged on as an administrator or a member of the Administrators group to complete this procedure. If your computer is connected to a network, network policy settings may also prevent you from completing this procedure.
To restart your computer by using a clean boot procedure, follow these steps if you are using Microsoft Windows XP:
Note You may experience a temporary loss of some services functionality when you follow these steps. Restoring the settings restores the functionality, but the original error message or behavior may return as a result. Click Start, and then click Run.In the Open box, type msconfig, and then click OK.On the General tab, click Selective Startup. Under Selective Startup, click to clear the following check boxes: Process SYSTEM.INI FileProcess WIN.INI FileLoad Startup ItemsOn the Services tab, click to select the Hide All Microsoft Services check box, and then click Disable All.Click OK, and then click Restart. To perform a clean boot procedure, click the Play button to view this streaming media demonstration.
To return from a clean boot state, click the Play button to view this streaming media demonstration.
For additional information or to view steps for other operating systems, click the following article number to view the article in the Microsoft Knowledge Base:
331796?(http://support.microsoft.com/kb/331796/) Games: How to perform a clean boot to prevent background programs from interfering with play If the issue continues to occur, go to the next method.
Method 2: Check the list of known issues The following programs are known to have this issue with Halo: Combat Evolved: Meaya Popup Killer-The file that is reported as being in memory is either the MK.dll file or the MK2.dll file. For additional information, visit the following Meaya Web site:
http://www.meaya.com(http://www.meaya.com) Microsoft provides third-party contact information to help you find technical support. This contact information may change without notice. Microsoft does not guarantee the accuracy of this third-party contact information.