Failed to load ASP.NET type?

I have two files in one directory, an ascx file and an ascx.cs file with a C # class defined inside it.

This is the code in my .ascx file

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Test.ascx.cs" Inherits="SITE.UI.Controls.Test" %> 

And this is the code in Test.ascx.cs:

 using System; using System.Web.UI; namespace SITE.UI.Controls { public partial class Test : System.Web.UI.UserControl { } } 

However, whenever I try to create a site, I always get this error:

Error 1 Failed to load type 'SITE.UI.Controls.Test'

I am sure that I should do something clearly wrong, but after an hour of beating I will not go anywhere.,.

+4
source share
3 answers

Go to web project properties -> Create settings and change the output path to bin \

If this does not work, check this article. Here are some solutions to this problem.

Let me know this when it is fixed or not :)

+3
source

I will talk about my case and what worked for me. I have a project that worked fine. For some known reason, he received a compilation / build error. I have user controls in the Management folder. After processing the compilation error for web handlers, I received a new set of errors for each user control in the Management folder. I tried many things, including deleting the constructor file (and creating another empty one), the error I received could not load the type "Name.Of.Class" (in the line of the directive # 1 <% @ Control%>).

My solution was: I added another parallel control named OriginalControlName2.ascx. Then I copied all the content from @ .ascx to @ 2.ascx and the same for ascx.cs. So far so good, don't compile the error for the new page / control. Then exclude the source file and change the file name # 2 to the original name. The error list has dropped to zero.

With all my experience, I don't know what the problem is, but I got a fix.

************** UPDATE ****************

every time I finish a set of files, it continues to the rest. I found that the <% @ Page / WebHandler / Control /%> directive has a CodeBehind attribute. When I changed it to CodeFile, the error disappeared from the list. This is much shorter than adding a new file and moving all the code.

Good luck.

+2
source

Just wanted to add what worked for me when I got the same error. I made an iisreset that solved the problem.

0
source

All Articles