PRB: "Could not load type" error message when you browse to .aspx page by using Visual C# .NET

Article translations Article translations
Article ID: 306155 - View products that this article applies to.
This article was previously published under Q306155
Expand all | Collapse all

On This Page

SYMPTOMS

When you browse to an .aspx page, you may receive one of the following error messages:
Could not load type 'Namespace.Global'.
-or-
Could not load type 'Namespace.PageName'.

CAUSE

These errors occur if the .aspx page or the Global.asax page contains a reference to a code-behind module and if the application has not been built.

RESOLUTION

Use one of the following methods to build the application:
  • Use the C# command line compiler (CSC.exe) to run the following command:
    csc /t:library /r:System.web.dll /out:mydll.dll myfile.cs
  • In Microsoft Visual Studio .NET, click Build on the Build menu.
NOTE: Microsoft Visual Basic .NET background compiles the project as soon as it is created. Because Visual C# .NET projects only background parse, you must explicitly build the application.

STATUS

This behavior is by design.

MORE INFORMATION

Steps to Reproduce the Behavior

  1. Start Visual Studio .NET.
  2. On the File menu, point to New, and then click Project.
  3. Click Visual C# Projects under Project Types, and then click ASP.NET Web Application under Templates.
  4. Right-click WebForm1.aspx, and then click View in Browser.

REFERENCES

For more information about building assemblies, visit the following MSDN Web site:
http://msdn.microsoft.com/en-US/library/b0b8dk77(v=vs.80)

Properties

Article ID: 306155 - Last Review: June 15, 2012 - Revision: 4.0
APPLIES TO
  • Microsoft ASP.NET 1.0
  • Microsoft Visual C# .NET 2002 Standard Edition
Keywords: 
kbcompiler kberrmsg kbprb kbwebforms KB306155

Give Feedback

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com