Error loading the webpart '' of type '

Jeewani Jayasuriya asked on May 27, 2020 17:32

Hi all,

I have created a custom webpart. I am getting an error saying "Error loading the webpart 'your_webpart' of type 'your_webpart'"

No coding done in my .ascx.cs file other than the normal code when you create a web part. Below code only I have

All I got below in my .ascx file. <%@ Control Language="C#" AutoEventWireup="true" Inherits="CMSWebParts_Campaigns_Check_User" CodeBehind="~/CMSWebParts/Campaigns/Check_User.ascx.cs" %>

I already have few custom web parts and I don't have any issue. But what ever the web part I am creating now I get "Error loading the webpart 'your_webpart' of type 'your_webpart'" error.

Please help me.

thanks

Recent Answers


Juraj Ondrus answered on May 28, 2020 06:22

What does the error in the Event log say? What is the .cs code like? Usually this kind of error is thrown when he code files are missing from the file system or there is something wrong with the actual web part code. Check also the Inherits="CMSWebParts_Campaigns_Check_User" - it has to be the same as in the code behind file.
Also, since you are using web application - make sure the web part code files are included into the project and that you can build the solution without errors.

0 votesVote for this answer Mark as a Correct answer

Jeewani Jayasuriya answered on May 29, 2020 11:20

Hi Juraj,

Please see below my .cs code .

region "Namespaces"

using System; using CMS.PortalEngine.Web.UI;

endregion

public partial class CMSWebParts_Campaigns_Check_User : CMSAbstractWebPart { #region Page Load protected void Page_Load(object sender, EventArgs e) { if (BookSellerSession.Current.GLN != null) Response.Redirect("~/Account/Special-Pages/Checkout/Shopping-Cart"); else Response.Redirect("~/Special-Pages/Checkout/Shopping-Cart"); } #endregion

}

This is all I got in my .ascx file

<%@ Control Language="C#" AutoEventWireup="true" Inherits="CMSWebParts_Campaigns_Check_User" CodeBehind="~/CMSWebParts/Campaigns/Check_User.ascx.cs" %>

Please see below my Event log.

EventID: 60228

EventType: E

EventTime: 5/29/2020 9:46:47 AM

Source: PortalEngine

EventCode: LoadWebPart

UserID: 53

UserName: administrator

IPAddress: 192.168.113.5

EventDescription: Message: Could not load type 'CMSWebParts_Campaigns_Check_User'.

Exception type: System.Web.HttpParseException Stack trace: 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 CMS.Base.Web.UI.ControlDefinition.Load(Page page) at CMS.PortalEngine.Web.UI.CMSWebPartZone.LoadWebPart(Control container, CMSWebPartZone zone, WebPartInstance part, Boolean reloadData, Boolean isVariant)

Message: Could not load type 'CMSWebParts_Campaigns_Check_User'.

Exception type: System.Web.HttpParseException Stack trace: 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)

Message: Could not load type 'CMSWebParts_Campaigns_Check_User'.

Exception type: System.Web.HttpException Stack trace: 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)

EventUrl: /special-pages/check-user

EventMachineName: DC16C132

EventUserAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36

EventUrlReferrer: http://172.16.20.195/account/products


Any help would be appreciated.

Thank you.

Regards, JJ

0 votesVote for this answer Mark as a Correct answer

Juraj Ondrus answered on May 29, 2020 11:38

The code looks OK. Since you are using web application - are the code files included into the project and solution in Visual Studio? Are you able to build the solution in Visual studio without any errors?

0 votesVote for this answer Mark as a Correct answer

Jeewani Jayasuriya answered on May 29, 2020 12:27

Code files are included in the project. I don't get any errors when I build the project. :(

I have few more web parts included in the project and all were ok. What ever the web part I am creating I get this issue now.

0 votesVote for this answer Mark as a Correct answer

Juraj Ondrus answered on May 29, 2020 12:55

I do not see anything obvious - I was able to create the web part just fine and register it in Kentico. I guess it will be something silly, small we are missing here. I would try creating and registering the web part from scratch again.

0 votesVote for this answer Mark as a Correct answer

Jeewani Jayasuriya answered on June 2, 2020 10:27

Hi, i did creating the web part from the scratch. Still no luck. Is it possible for you to log and check what's wrong with this?

Please someone help me. I am so desperate.

Thanks!

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.