Question

I am trying to add code behind file for .aspx file of sharepoint site pages. I followed the instructions given on this link Here

But I am getting this error

Could not load the assembly 'CustomPage, Version=1.0.0.0, Culture=neutral, PublicKeyToken=d8b1948ab52231c9'. Make sure that it is compiled before accessing the page

I have installed the .dll file in GAC. I have typed the above assembly details using gacutil.

The page directive looks as follows :

    <%@ Assembly Name="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"%> 
<%@ Page MasterPageFile="~masterurl/default.master" 
meta:progid="SharePoint.WebPartPages.Document" 
Language="C#" Inherits="CustomPage.CustomFile, CustomPage, Version=1.0.0.0, Culture=neutral, PublicKeyToken=d8b1948ab52231c9" %>
 <%@ Import Namespace="Microsoft.SharePoint.WebPartPages" %> <%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%@ Import Namespace="Microsoft.SharePoint" %> <%@ Assembly Name="Microsoft.Web.CommandUI, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

And I am not able to find any error in my .aspx page too. Is the error because of some safe controls of sharepoint.

Update: found the culprit. The code-behind file was initally compiled against the .Net 4.5 framework; once compiled against the 3.5 version (SP 2010 requires that), everything started to work.

Was it helpful?

Solution

The assembly declaration seems wrong. Report here the Page directive, so we can see what's wrong.

Anyway, it should resemble this:

Inherits="AssemblyNameSpace.CustomPageClassName, AssemblyNameSpace,Version=1.0.0.0,..."
Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top