Sunday, April 13, 2008

Could Not Load Type 'xxxxxxx.xxx.UI.Admin.Test' - ASP.NET 2.0 Error and Solutions

When an .aspx page of ASP.NET 2.0 Web Application is viewed, at times we get the error "Could not load type xxxx'. The sample error message displayed is as follows


Parser Error

Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

Parser Error Message: Could not load type 'xxxxxxx.Web.UI.Admin.Test'.

Source Error:

Line 1: <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Test.aspx.cs" Inherits="xxx.Web.UI.Admin.Test" %>
Line 2:
Line 3: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/ DTD/xhtml1-transitional.dtd">


Source File: /Test.aspx    Line: 1


There are several reasons why we get the error. We will present you the major reasons why we get the error and also how to correct them

Reason 1: Invalid Build Output Directory

If the build output folder of the web application  is set to any folder other than Bin\, you would get this error. For example pointing the build output folder to ..\CommonBin\ or C:\Bin is not a valid configuration and this invalid configuration causes the Could not load type error.

To solve the error always point your output folder of the web application project to \bin

Reason 2: Referring to Code Behind Modules Without Building The Application

If you refer to any code behind module in .aspx pages or Global.asax page and the web application has'nt been built then you get this error.

To solve the error, build the web application using Build option(Ctrl+Shift+B) available  in Visual Studio.NET development environment or use command line compilers like CSC.

Refer to Microsoft support page for elaborated information

Reason 3: Incorrect asp.net version configuration in IIS

Incorrect asp.net version configuration in IIS server also causes this error. For example, if you are using Visual Studio 2005 with an  IIS configured with ASP.NET v1.1 is an invalid configuration.

In order to solve the problem follow these simple steps

  1. Go to Start Menu, click on Run (alternatively use Win Key + R )
  2. Type INetMgr and press enter to open Internet Information Services Application
  3. Expand the tree node displaying local computer name and navigate to Web Sites-->Default Web Site
  4. Right click on Default Web Site node and select the popup menu option Properties

  1. Navigate to ASP.NET tab in the properties page and set the version to 2.xxxx(for Visual Studio 2005) or 1.xxxx(for Visual Studio 2003)

3 Comments:

Anonymous said...

Hello,

Please help me. I am getting this error at online server. Please let me know what would be the reason for this.

***************************************

Server Error in '/' Application.
--------------------------------------------------------------------------------

Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

Parser Error Message: Could not load type 'SplendidCRM.OutingEvents.Default'.

Source Error:




Source File: /OutingEvents/default.aspx Line: 1


--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.3053; ASP.NET Version:2.0.50727.3053

***************************************

Thanks
---
http://360by2.blogspot.com/2009/01/tips-to-get-started-with-ms-internet.html

Anonymous said...

These guidelines helped me solve the problem. Especially the last step.

Gopinath: double-check your steps.

Mikelito said...

Put the bin directory just below the top application, it doesn't matter if you configure only a folder, .NET Framework looks for the assembly in the bin folder below the current application.