Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

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


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'.

↑ Back to the top


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.

↑ Back to the top


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.

↑ Back to the top


Status

This behavior is by design.

↑ Back to the top


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.

↑ Back to the top


References

For more information about building assemblies, visit the following MSDN Web site:

↑ Back to the top


Keywords: kbvs2003swept, kbaspwpswept, kbcompiler, kbdsupport, kberrmsg, kbprb, kbwebforms, kb

↑ Back to the top

Article Info
Article ID : 306155
Revision : 3
Created on : 4/17/2018
Published on : 4/17/2018
Exists online : False
Views : 863