.NET Questions and Solutions

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 Tagged ‘Visual’

“Internal Exception 0×800a2328″ error message when you run a WebClass application

Symptoms
If you have Microsoft Visual Studio 6.0 Service Pack 4 or Visual Studio 6.0 Service Pack 5 installed, and you try to run a Visual Basic 6.0 WebClass application outside the IDE, you receive an error message that is similar to the following:

Error:0×800a2328 Internal Exception has occured (asp line 13) calling thewebclass runtime. Note In this error message, “occured” is a misspelling of the word “occurred.”
This problem does not occur if you have an installation of Visual Studio 6.0 that does not have any service packs installed.
Resolution
To resolve this problem, obtain the latest service pack for Visual Studio 6.0. For more information, click the following article number to view the article in the Microsoft Knowledge Base:
834001?(http://support.microsoft.com/kb/834001/) List of bugs that are fixed in Visual Studio 6.0 Service Pack 6

Automation server can’t create object

When you display the Start Page or when you use any wizards in Microsoft Visual Studio (including when you create a new project or add classes), you receive the following error message:

“Automation server can’t create object”

This behavior may be caused by a corrupted Windows Script component.

To resolve this problem, download and install the latest Windows Script.

Visual Studio includes an Object Model for extending and automating the IDE. The Start Page and most wizards that are provided by Visual Studio are written in scripting language. If the script engine is corrupted, the wizards cannot run properly.

How to serialize an object to XML by using Visual C#

Requirements

The following list outlines the recommended hardware, software, network infrastructure, and service packs that are required:

  • Microsoft Visual Studio

This article assumes that you are familiar with the following topics:

  • General familiarity with XML
  • General familiarity with Visual C#
XML Serialization

Serialization is the process of taking the state of an object and persisting it in some fashion. The Microsoft .NET Framework includes powerful objects that can serialize any object to XML. The System.Xml.Serialization namespace provides this capability.
Follow these steps to create a console application that creates an object, and then serializes its state to XML:

  1. In Visual C#, create a new Console Application project.
  2. On the Project menu, click Add Class to add a new class to the project.
  3. In the Add New Item dialog box, change the name of the class to clsPerson.
  4. Click Add. A new class is created.
    Note In Visual Studio .NET 2003, click Open.
  5. Add the following code after the Public Class clsPerson statement

     public   string FirstName;
     public   string MI;
     public   string LastName;
  6. Switch to the code window for Program.cs in Visual Studio or for Class1.cs in Visual Studio .NET 2003.
  7. In the void Main method, declare and create an instance of the clsPerson class:

    clsPerson p = new clsPerson();
  8. Set the properties of the clsPerson object:

    p.FirstName = "Jeff";
    p.MI = "A";
    p.LastName = "Price";
  9. The Xml.Serialization namespace contains an XmlSerializer class that serializes an object to XML. When you create an instance of XmlSerializer, you pass the type of the class that you want to serialize into its constructor:

    System.Xml.Serialization.XmlSerializer x = new System.Xml.Serialization.XmlSerializer(p.GetType());
  10. The Serialize method is used to serialize an object to XML. Serialize is overloaded and can send output to a TextWriter, Stream, or XMLWriter object. In this example, you send the output to the console:

    x.Serialize(Console.Out,p);
    Console.WriteLine();
    Console.ReadLine();