0

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.

1 Answer 1

3

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,..."
7
  • I have updated my question @MdMazzotti Commented Apr 22, 2015 at 9:12
  • @ABeginner try adding this: <%@ Assembly Name="CustomPage.CustomFile, CustomPage, Version=1.0.0.0, Culture=neutral, PublicKeyToken=d8b1948ab52231c9" %> Commented Apr 22, 2015 at 9:16
  • I got this error on adding the assembly directive : The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047) Commented Apr 22, 2015 at 9:24
  • @ABeginner Are you sure you compiled it targeting the .NET 3.5 framework version? Commented Apr 22, 2015 at 9:26
  • No, I compiled it in .net framework 4.5 @MdMazzotti Commented Apr 22, 2015 at 9:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.