If you are getting “Method not found” (MissingMethodException) error in SharePoint 2010

“Method not found” error i admit its my favorite ūüôā If you get this MissingMethodException from any of your build in SharePoint assembly for example below “Microsoft.SharePoint.Library” the first place you may check the dlls versions. This error usually caused by some version mismatch¬†between¬†your related dll version and SharePoint version.

You can see the error samples below:
Exception information:
Exception type: MissingMethodException
Exception message: Method not found: ‘Void Microsoft.SharePoint.Library.SPRequestInternalClass.AddOrUpdateItem(System.String, System.String, Boolean, Boolean, Boolean, Boolean, Boolean, Int32 ByRef, System.String ByRef, System.Guid, Boolean, System.String, System.Object ByRef, System.Object ByRef, System.Object ByRef, Boolean, Boolean, Boolean, Boolean, System.String, Microsoft.SharePoint.Library.ISP2DSafeArrayWriter, Microsoft.SharePoint.Library.ISP2DSafeArrayWriter, Microsoft.SharePoint.Library.ISP2DSafeArrayWriter)’.

Stack trace:    at Microsoft.SharePoint.Library.SPRequest.AddOrUpdateItem(String bstrUrl, String bstrListName, Boolean bAdd, Boolean bSystemUpdate, Boolean bPreserveItemVersion, Boolean bPreserveItemUIVersion, Boolean bUpdateNoVersion, Int32& plID, String& pbstrGuid, Guid pbstrNewDocId, Boolean bHasNewDocId, String bstrVersion, Object& pvarAttachmentNames, Object& pvarAttachmentContents, Object& pvarProperties, Boolean bCheckOut, Boolean bCheckin, Boolean bMigration, Boolean bPublish, String bstrFileName, ISP2DSafeArrayWriter pListDataValidationCallback, ISP2DSafeArrayWriter pRestrictInsertCallback, ISP2DSafeArrayWriter pUniqueFieldCallback)
   at Microsoft.SharePoint.SPListItem.AddOrUpdateItem(Boolean bAdd, Boolean bSystem, Boolean bPreserveItemVersion, Boolean bNoVersion, Boolean bMigration, Boolean bPublish, Boolean bCheckOut, Boolean bCheckin, Guid newGuidOnAdd, Int32& ulID, Object& objAttachmentNames, Object& objAttachmentContents, Boolean suppressAfterEvents, String filename, Boolean bPreserveItemUIVersion)
   at Microsoft.SharePoint.SPListItem.UpdateInternal(Boolean bSystem, Boolean bPreserveItemVersion, Guid newGuidOnAdd, Boolean bMigration, Boolean bPublish, Boolean bNoVersion, Boolean bCheckOut, Boolean bCheckin, Boolean suppressAfterEvents, String filename, Boolean bPreserveItemUIVersion)
   at Microsoft.SharePoint.SPListItem.Update()
   at Microsoft.SharePoint.WebControls.SaveButton.SaveItem(SPContext itemContext, Boolean uploadMode, String checkInComment)
   at Microsoft.SharePoint.WebControls.SaveButton.OnBubbleEvent(Object source, EventArgs e)
   at System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)
   at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

So what could cause this issue
1) Unsuccessful upgrade or a corrupted installation.
2) Custom solutions that referenced old dlls
3) Deploying SharePoint solutions which is accidentally overwriting old dll on new version.
4) Unnecessery GAC registrations for build-in SharePoint DLLs

In this scenario we don’t have any custom solutions . So we may facing with first issue above, so how to fix the issue:
1) Define that which dll in use and this exception has thrown up. Answer for this scenario is “Microsoft.SharePoint.Library.dll”
2) Check the all dll versions in your system and compare with your SharePoint Build Number from Central Administration- > Migration and Upgrade -> Check product installation and patch status.
Here you can find powershell commands for searching versions of specific file in your system.
3) Correct dll version if you have orginal version of this old dll.
4) Upgrade your SharePoint for  newer version of Cumulative Update than your build will solve this issue.

By the way if you are thinking the problem caused by a Custom Solution you may check fallowing article:

Have a nice day.


Getting null reference exception when try to open list settings (Listedit.aspx) for Sharepoint 2010

This is a typical¬† error scenario that you have if you move or copy some sharepoint core¬†dll’s which is referenced fr0m another folder.There is common mistake when developing custom applications that moving and copying sharepoint core¬†dll’s to where is not in original folder (for example coping¬†Microsoft.Sharepoint.dll to¬†BIN folder of web application)¬†¬†or unnecesserly register in GAC (for example registering Microsoft.Sharepoint.ApplicationPages.dll to GAC).

Why is this dangerous ? i can simply say when you upgrade or install any patch on sharepoint , the copied dlls form original location  can not be upgraded  by default .So this cause a huge anomality in your system. DLL version integrity is very important issue for every Microsoft product. So be careful for this operations , after all if you still need to copy or move operation, that upgrading copied dlls is your responsibility.

So lets keep going with our error :

when you click the one of list’s list settings (listedit.aspx) you can probably getting fallowing error in application event logs:

Exception information:
Exception type: NullReferenceException
Exception message: Object reference not set to an instance of an object.

Stack trace:    at Microsoft.SharePoint.ApplicationPages.ListEditPage.SetSectionLinks()
at Microsoft.SharePoint.ApplicationPages.ListEditPage.OnLoad(EventArgs e)
at ASP._layouts_listedit_aspx.OnLoad(EventArgs e) in c:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\listedit.aspx:line 25
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

And if you enable custom errors from  in your web.config which is in Layouts folder.You can see the error in browser:

NullReferenceException: Object reference not set to an instance of an object.]
Microsoft.SharePoint.ApplicationPages.ListEditPage.SetSectionLinks() +426
Microsoft.SharePoint.ApplicationPages.ListEditPage.OnLoad(EventArgs e) +896
ASP._layouts_listedit_aspx.OnLoad(EventArgs e) +290
System.Web.UI.Control.LoadRecursive() +65
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2427

For resolving this issue you should find the related copied assembly files which according this scenario is Microsoft.Sharepoint.ApplicationPages.dll in use for unfamiliar locations.

the orginal location for this dll is  Drive:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\CONFIG\BIN

1) First Check the GAC this dll should not be added to GAC if it is upgrade latest correct version or delete the dll.
2) Check other possible existance may it be used in BIN folders of web applications. For getting all list of any dll location you can use this script:
http://blog.bugrapostaci.com/2011/12/26/powershell-find-files-with-versions/ this powershell command gives you a list that defined dll locations and versions.

For best practise if you need any reference to Sharepoint DLL’s use and reference¬†them in original locations .if not you always remember to upgrade¬†latest versions where it have been that is your resposibility.

See you next time.







Register your dll’s to GAC with Visual Studio IDE

In this article we will create an external tool for registering our dlls to GAC .

1) Click in your VS.IDE menu Tools -> External Tools…

2) Click to Add button

Title = Register GAC

Command = ÔĽŅ¬†ÔĽŅC:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin\gacutil.exe

Arguments = -i $(TargetPath)

3) Make checked “Use Output window” for results

4) Click OK .

Now you can use your new external tool in your IDE’s -> Tools Menu…


Some tools save time or not ? bye now…

Ninject with Sharepoint

Ninject is one of the best tool for dependency injection that i  use. I tell about how to use with sharepoint in this article.   

Ninject Source Code,
Microsoft Sharepoint Library.   

First i want to say that i m using Sharepoint with Framework 3.5 and you can find how to configure sharepoint with working Sharepoint in this article of mine.http://blog.bugrapostaci.com/2009/11/12/step-by-step-configure-your-sharepoint-running-with-net-framework-3-5/   

Thats why one of the reason  i recompile with Ninject Library with Framework 3.5  for this but if you use Framework 2.0 its not necessery for you. if  you mind you learn about mantioned in my another article.http://blog.bugrapostaci.com/2010/02/22/solved-ninject-system-runtime-compilerservices-extensionattribute-is-defined-in-multiple-assemblies/   

For working with Ninject in Asp.net you should inherit Global class with Ninject.Framework.Web.NinjectHttpApplication but in sharepoint standart Global class is derived from Microsoft.Sharepoint.ApplicationRuntime.SPHttpApplication. the second reason that i recompile ninject source.   

Example of Standart Sharepoint Global.asax:
[Drive]:\inetpub\wwwroot\wss\VirtualDirectories\[Your app port]\Global.asax   

<%@ Assembly Name=”Microsoft.SharePoint”%>
<%@ Application Language=”C#” Inherits=”Microsoft.SharePoint.ApplicationRuntime.SPHttpApplication” %>¬†¬†¬†

You can download Ninject Source Code from project site of Ninject.

Than i created a new project in Framework folder. And add references of Microsoft.Sharepoint library.
My project’s namespace is Ninject.Framework.Web.Sharepoint.I create a class named “NinjectSPHttpApplication”
that just inherits SPHttpApplication inspite of  HttpApplication. All members code as same as Ninject.Framework.Web.NinjectHttpApplication class.   

namespace Ninject.Framework.Web.Sharepoint   


    /// <summary>   

¬†¬†¬† /// A <see cref=”HttpApplication”/> that creates a <see cref=”IKernel”/> for use throughout¬†¬†¬†

    /// the application.   

    /// </summary>   

    public abstract class NinjectSPHttpApplication : SPHttpApplication   


¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†….Same as NinjectHttpApplication¬†¬†¬†




And build the all solution. 

You can download source code of my project :

And i also add functionalities of UserControlBase and WebControlBase classes for injection about a good case.
Thats the page:http://stackoverflow.com/questions/1274026/ninject-asp-net-and-custom-controls

After your ninject dlls ready you should add this dlls to your 80/BIN folder and register with GAC and add to your sharepoint application web.config file. I don’t tell how to register custom assemblies in sharepoint asume that you know already.¬†

After you complete this you can change that your Global.asax file in your Sharepoint wss root folder.
[Drive:]\inetpub\wwwroot\wss\VirtualDirectories\[Your app port]\Global.asax Like: 

<%@ Import Namespace=”Ninject.Framework.Web.Sharepoint” %>
<%@ Import Namespace=”Ninject.Core” %>
<%@ Application Language=”C#”¬†inherits=”Ninject.Framework.Web.Sharepoint.NinjectSPHttpApplication” %>¬†

<SCRIPT language=”C#” runat=”server”>¬†¬†¬†¬†
    protected override IKernel CreateKernel()
        IKernel kernel = new StandardKernel(new SharePointUnitTestModule() );
        return kernel;
    public class SharePointUnitTestModule : StandardModule
        public override void Load()
          ...Your codes here.

Keep going with Part 2: