Answered Cannot import C# library in sharepoint 2010 application page

  • Saturday, May 26, 2012 4:07 AM
     
      Has Code

    I want to reference a class library method inside the application aspx page but I keep getting the dreaded Yellow Screen of Death with the error message

    CS0103: The name 'Common' does not exist in the current context.

    I followed the steps mentioned here to add the project to GAC and I also restarted IIS via IIS Manager.

    Here's my application page:

    <%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
    <%@ Import Namespace="Microsoft.SharePoint.ApplicationPages" %>
    <%@ 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" %>
    <%@ Register Tagprefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
    <%@ Import Namespace="Microsoft.SharePoint" %>
    <%@ Assembly Name="Microsoft.Web.CommandUI, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ApplicationPage1.aspx.cs" Inherits="SharePointProject1.Layouts.SharePointProject1.ApplicationPage1" DynamicMasterPageFile="~masterurl/default.master" %>
    
    <asp:Content ID="PageHead" ContentPlaceHolderID="PlaceHolderAdditionalPageHead" runat="server">
    
    </asp:Content>
    
    <asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server">
    <asp:Label ID="lblTest" runat="server" />
    <%= Common.Lib.Utility.GetStatusImage("approved") %>
    </asp:Content>
    
    <asp:Content ID="PageTitle" ContentPlaceHolderID="PlaceHolderPageTitle" runat="server">
    Application Page
    </asp:Content>
    
    <asp:Content ID="PageTitleInTitleArea" ContentPlaceHolderID="PlaceHolderPageTitleInTitleArea" runat="server" >
    My Application Page
    </asp:Content>
    


    ---
    Pre-Sales Consultant (Microsoft Business Intelligence Solutions)
    Tech One Global

All Replies

  • Saturday, May 26, 2012 7:15 AM
     
     

    did you Imported the name space of that C# library in a page with its version, public key token ?


    Regards, Dharnendra Shah, MCTS,MCPD - Sharepoint 2010 Application Development Blog: http://ds-sharepoint2010blogs.blogspot.in/ Email: shahdg2003@gmail.com

  • Saturday, May 26, 2012 7:24 AM
     
     
    Yes I tried importing the namespace as well but I didn't use any version or public token. Where do I get the version and public token?

    ---
    Pre-Sales Consultant (Microsoft Business Intelligence Solutions)
    Tech One Global

  • Saturday, May 26, 2012 7:26 AM
     
     Answered

    Go to GAC,

    see the properties of DLL


    Regards, Dharnendra Shah, MCTS,MCPD - Sharepoint 2010 Application Development Blog: http://ds-sharepoint2010blogs.blogspot.in/ Email: shahdg2003@gmail.com

    • Marked As Answer by Shimin Huang Wednesday, June 06, 2012 7:59 AM
    •