0

Create new Project with two custom class library,signing that assembly with key,

create one custom page, And deploy through SP designer

<%@ Register TagPrefix="DataEntities" Namespace="SPTestHnG.DataEntities"
    Assembly="SPTestHnG.DataEntities, PublicKeyToken=b77a5c561934e089" %>
<%@ Import Namespace="Microsoft.SharePoint.ApplicationPages" %>
<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Assembly Name="Microsoft.Web.CommandUI, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

DemoPage

But while shown preview in browser, error:

"Could not load file or assembly 'SPTestHnG.DataEntities, PublicKeyToken=b77a5c561934e089' or one of its dependencies"

Update : I check GAC folder"C:\Windows\Microsoft.NET\assembly\GAC_MSIL" where assembly file is there

Update 2 :: If I'm load "<%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>" then also gives a error Could not load file or assembly '$SharePoint.Project.AssemblyFullName$' or one of its dependencies

  • There are two GACs. c:\windows\assembly for assemblies built .NET up to 3.5 and c:\windows\microsoft.net\assembly for assemblies for .NET 4.0 and up. Which version of .NET did you use and did you check the corresponding GAC location? – Erik Perez Dec 10 '15 at 5:41
  • I found in "C:\Windows\Microsoft.NET\assembly\GAC_MSIL" not in assembly folder..I deploy sharepoint directly so assembly in GAC_MSIL..am i right? @Erik – Amit Koyani Dec 10 '15 at 5:55
  • 1
    Is you assembly strong name correct? Shouldn't it have the version number and culture also? Or, are there assemblies that your assembly is referencing that aren't deployed to the correct place? – Erik Perez Dec 10 '15 at 6:07
  • If I'm load "<%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>" then also gives a error Could not load file or assembly '$SharePoint.Project.AssemblyFullName$' or one of its dependencies @Erik – Amit Koyani Dec 10 '15 at 6:14
  • How are you deploying the assembly to the GAC? Are you using Visual Studio to create a solution package? – Erik Perez Dec 10 '15 at 6:49
1

Your DLL must be declared as safe in the web.config of the Web app:

<SafeControl Assembly="SPTestHnG.DataEntities, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" Namespace="SPTestHnG.DataEntities" TypeName="*" Safe="True" AllowRemoteDesigner="True" />

However, the best practice is to make it registered as part of a WSP deployment (Visual Studio would automatically include necessary XML declaration in the manifest.xml file of the WSP at publication time).

| improve this answer | |
  • I checked ...in my inetpub's web.config file declare in safe control that assembly already @Evariste – Amit Koyani Dec 10 '15 at 6:51
  • 1
    Also, be sure to add the reference in SPD exactly as it appears in the web.config, e.g. <%@ Register TagPrefix="DataEntities" Namespace="SPTestHnG.DataEntities" Assembly="SPTestHnG.DataEntities, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" %> – Evariste Dec 10 '15 at 7:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.