SharePoint 'Could not load type' error

by ZebSadiq 11. August 2010 22:08

Every now and then, I come across an error that seems to be so simple, yet after trying all the obvious remedies, I'm left the wonder whether the resulting error is unsolvable by some form a memory loss in my head, or something bizarre built into the third party system which I'm trying to wrestle.

Recently I came across such a situation and I spent a bit of time trying to figure it out until a colleague told me something about SharePoint that I didn't know.

Lets summarise what happened.

What I was trying to do:
Add a web part that loads a user control from the CONTROLTEMPLATES  directory at runtime.

The error:

Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

Parser Error Message: Could not load type 'MyProject,MyClient.UserControl.MyControl'.

Source Error:

<%@ Control Language="C#" AutoEventWireup="true" Inherits="MyProject,MyClient.UserControl.MyControl" %>

The Solution:
Fully qualify  the assembly information inside the control.

<%@ Control Language="C#" AutoEventWireup="true" Inherits="MyProject,MyClient.UserControl.MyControl" %>


<%@ Control Language="C#" AutoEventWireup="true" Inherits="MyProject,MyClient.UserControl.MyControl,, MyAssemblyName, Version=, Culture=neutral, PublicKeyToken=123456123456123" %>

So what's the issue:
If you deploy the assembly to the bin folder, SharePoint doesn't need your ascx files to fully qualify the assembly information. Whereas, If you deploy your assembly to the GAC, full qualification of assembly information inside the ascx/aspx file is required.

It may be an obvious solution if you're coding something from scratch but since I was porting some code from one project to another, I was very confused about why the code didn't work like the other project.  Of course the other project was deploying the assembly to the bin folder.

Best to take note of such subtle differences I suppose.

Tags: , ,

C# | SharePoint 2007


10/25/2012 8:44:36 PM #

Pingback from

BinaryJam » Some Extra Notes on using Rendering Templates | Reply

9/10/2017 4:01:29 PM #

Pingback from

Parser Error Could Not Load Type Inherits – | Reply

Add comment

  Country flag

  • Comment
  • Preview


<<  May 2024  >>

View posts in large calendar