本文介绍了无法加载类型“用户控件"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在sharepoint 2010中还原了一个站点.但是,当我运行它时,它会弹出有关用户控件的错误.即

I have restored a site in sharepoint 2010. But when I run it, it pops the error about the user control.i.e.

Could not load type 'Newsletter.Web.Applications.Subscribers.AddSubscriberStep1'.

这是LOG中的错误描述:

Here is the error description from LOG:

System.Web.HttpException: Could not load type 'Newsletter.Web.Applications.Subscribers.AddSubscriberStep1'.    at System.Web.UI.TemplateParser.GetType(String typeName, Boolean ignoreCase, Boolean throwOnError)     at System.Web.UI.TemplateParser.ProcessInheritsAttribute(String baseTypeName, String codeFileBaseTypeName, String src, Assembly assembly)     at System.Web.UI.TemplateParser.PostProcessMainDirectiveAttributes(IDictionary parseData)   ac3fc84c-11f3-46a0-bea5-930c43627627

我已经将该用户控件所在的项目部署到了​​,但是仍然存在相同的错误.我要去哪里错了?请帮助我.

I have deployed the project where that user control resides but still the same error. Where am I going wrong? Kindly assist me.

推荐答案

以下示例显示了对Web UserControl的作用,但对Page,Master Page和WebPart的作用相同:

The following example shows that for a Web UserControl, but it works the same for a Page, a Master Page and a WebPart:

  <!-- change this (ASP.NET Web Site version) -->
 <%@ Control Language="C#" AutoEventWireup="true"
 CodeFile="WebUserControl.ascx.cs"
 Inherits="Controls_WebUserControl" %>

 <!-- into this (ASP.NET Web Application version), or vice versa -->
 <%@ Control Language="C#" AutoEventWireup="true"
 CodeBehind="WebUserControl.ascx.cs"
 Inherits="Controls_WebUserControl" %>

这是您摆脱该烦人的错误所需要做的一切!

That’s all you need to do to get rid of that annoying error!

原因?如果您具有"ASP.NET Web应用程序",则Microsoft需要在Page,Control或Master指令中使用CodeBehind,如果您具有"ASP.NET网站",则编译器将期望使用CodeFile.我不知道为什么存在这种差异,这很烦人,您可以在发现之前永远盯着代码,但这是这种情况的解决方案

The reason? If you have an "ASP.NET Web Application", Microsoft needs CodeBehind in the Page, Control or Master directive, if you have an "ASP.NET Web Site", the compiler expects CodeFile instead. I have no idea why this difference exists, it is very annoying and you can stare forever at your code before you find it, but this is the solution for this scenario

这篇关于无法加载类型“用户控件"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-06 00:58