Umbraco - Could not load type 'usercontrols_NewContactUs'

881 views Asked by At

I am trying to duplicate an existing Form in Umbraco (Contour is not installed). I have copied the following files:

from: \my-site\usercontrols\Common\ContactUsForm.ascx <%@ Control Language="C#" AutoEventWireup="true" Inherits="usercontrols_ContactUs" Codebehind="ContactUsForm.ascx.cs" %>

to: \my-site\usercontrols\Common\NewContactUsForm.ascx <%@ Control Language="C#" AutoEventWireup="true" Inherits="usercontrols_NewContactUs" Codebehind="NewContactUsForm.ascx.cs" %>

from: \my-site\usercontrols\Common\ContactUsForm.ascx.cs public partial class usercontrols_ContactUs : System.Web.UI.UserControl {...}

to: \my-site\usercontrols\Common\NewContactUsForm.ascx.cs public partial class usercontrols_NewContactUs : System.Web.UI.UserControl {...}

I have created a macro which points to the NewForm, and added the macro to a new page.

I don't have Visual Studio installed - could there be a compilation error in my codeBehind class?

Error details are below:

Macro created and added to form gives error: Error creating control (usercontrols/Common/NewContactUsForm.ascx). Maybe file doesn't exists or the usercontrol has a cache directive, which is not allowed! See the tracestack for more information!


Error reading usercontrols/Common/NewContactUsForm.ascx The following list shows the Public Properties from the Control. By checking the Properties and click the "Save Properties" button at the bottom, umbraco will create the corresponding Macro Elements.

System.Web.HttpParseException (0x80004005): Could not load type 'usercontrols_NewContactUs'. ---> System.Web.HttpParseException (0x80004005): Could not load type 'usercontrols_NewContactUs'. ---> System.Web.HttpException (0x80004005): Could not load type 'usercontrols_NewContactUs'. 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) at System.Web.UI.TemplateParser.ProcessException(Exception ex) at System.Web.UI.TemplateParser.ParseStringInternal(String text, Encoding fileEncoding) at System.Web.UI.TemplateParser.ParseString(String text, VirtualPath virtualPath, Encoding fileEncoding) at System.Web.UI.TemplateParser.ParseString(String text, VirtualPath virtualPath, Encoding fileEncoding) at System.Web.UI.TemplateParser.ParseFile(String physicalPath, VirtualPath virtualPath) at System.Web.UI.TemplateParser.ParseInternal() at System.Web.UI.TemplateParser.Parse() at System.Web.Compilation.BaseTemplateBuildProvider.get_CodeCompilerType() at System.Web.Compilation.BuildProvider.GetCompilerTypeFromBuildProvider(BuildProvider buildProvider) at System.Web.Compilation.BuildProvidersCompiler.ProcessBuildProviders() at System.Web.Compilation.BuildProvidersCompiler.PerformBuild() at System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath) at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate) at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate) at System.Web.UI.TemplateControl.LoadControl(VirtualPath virtualPath) at umbraco.developer.assemblyBrowser.Page_Load(Object sender, EventArgs e)

1

There are 1 answers

4
Jannik Anker On BEST ANSWER

Yup, it's a compilation issue. The class NewContactUsForm doesn't exist until you compile it. In a bind, you could move the code from NewContactUsForm.ascx.cs into a C# script block directly on NewContactUsForm.ascx and remove the codebehind="..." and inherits="..." refrences entirely. That way you won't have to compile.