could not load type ‘projectname.assemblyname.pagename’

22 09 2008

When doing ASP.Net development hosted in SharePoint, I occasionally found the following error when opening certain page, and the page that showed this error changes, one day it could be page A, another day it could be page B and this appears at random times. By turning off custom errors and showing stack trace I got the following error:

Server Error in ‘/’ Application.


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 ‘projectname.assemblyname’.

Source Error:

Line 1: <%@ Page Language=”C#” MasterPageFile=”~masterurl/default.master”

Line 2: CodeBehind=”MyPage.aspx.cs” Inherits=”projectname.assemblyname.MyPage”

Line 3: meta:progid=”SharePoint.WebPartPage.Document” %>


Source File: /subsite/MyPage.aspx Line: 1


Version Information: Microsoft .NET Framework Version:2.0.50727.832; ASP.NET Version:2.0.50727.832

I didn’t have this error in development server but constantly having this error at random times in client’s server. Doing IIS Reset or Recycle the Application Pool seems to get rid of the issue only for temporary. My guess is the assembly is not being “linked” properly after some process running in the server. I’ve placed the assembly in the bin folder of the web application but the issue always appear again and again at random time. I’ve added the assemby in web.config as well in the safe control section.

When googling about the issue I found a post that’s indirectly linked to this issue. I’m not sure if this has to do with using AAM (Alternate Access Mapping) or not but somehow the assembly at certain time “looses” the “mapping” to the location of the assembly.

So, from the post, I forgot the link to it, but it’s an old post about ASP, will post it here once I found it (it was burried deep inside google search result), I tried adding below section into web.config file of the SharePoint web application right inside the <assemblies> tag:

<compilation batch=”false” debug=”false”>
<assemblies>
<add assembly=”Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c” />
<add assembly=”projectname.assemblyname, Version=1.0.0.0, Culture=neutral, PublicKeyToken=uniqueassemblytoken” />
</assemblies>

This has resolved the issue for me.

If there’s any one know why is this happening at random time and the cause please let me know. I’ll updated the post.





How to show icon for PDF documents in SharePoint 2007

31 07 2008

I was recently given a task to upload a PDF documents in MOSS’ document library for the Web App we (me and team) created for a client. Uploading it should be the easy part, but to see that SharePoint, by default, doesn’t recognize or show the PDF icon next to it really bothers me. Obviously, Microsoft office file extensions or file extensions “created” by Microsoft are the ones recognized by MOSS.

After googling around a bit and found very littlt information about it, I found this blog by Chad. Unfortunately, it was for WSS. Fortunately, only a little modification is needed for MOSS. Here are the steps:

  1. In your 12 hive directory, find the TEMPLATE\XML folder. The full path usually is C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\XML. Open the DOCICON.XML using your favourite text editor.
  2. Add an entry inside ByExtension tag as follows:
    <Mapping Key="pdf" Value="pdf16.gif"/>
    pdf16.gif is a 16 x 16 gif image file name of the PDF icon, find one and copy it into TEMPLATE\IMAGES folder in the 12 hive.
  3. Save your DOCICON.XML file and do IIS reset.

You might want to do backup on DOCICON.XML before and after you modified it because future updates/patches might overwrite your XML files. Chad’s blog already provide the resources and the modified XML file and he even wrote a batch file that do this automatically, but do modify the source first if you are going to do this on MOSS.

You can get the official PDF icon in here along with its Ts & Cs. This is the 16 x 16 gif (just save the picture):PDF icon

Happy SharePoint-ing…