Resolved: Could not load file or assembly ‘Microsoft.SharePoint.Search, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c’ or one of its dependencies…

I have a solution that contains SharePoint dll’s reference. Whenever I run the solution, start page get crash and show me this error.

“Could not load file or assembly ‘Microsoft.SharePoint.Search, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c’ or one of its dependencies. An attempt was made to load a program with an incorrect format.”

Well every time I run the project it creates Microsoft.SharePoint.Search.dll and Microsoft.SharePoint.Search.xml inside the bin folder and it creates the problem. Well there are lots many things have written on web regarding this problem. I follow all these things but could not get rid of this error. Finally I decided to fix this problem according to my way. So below are the steps to fix this problem permanently.

1.       Inside solution explorer (Visual Studio), select the project and right click on that.

2.       From context menu, click on properties.

3.       When properties page opens, Click on Build Events.

4.       Under Post – build event command line, copy and  paste below lines

cd $(TargetDir)

del Microsoft.SharePoint.Search.dll

del Microsoft.SharePoint.Search.xml

Now save the project, build the project and run. Now above mentioned error will never irritate you. :)

About these ads

6 Comments (+add yours?)

  1. JeroenW
    Mar 12, 2011 @ 01:19:56

    Awesome.. Had the same problem using Commerce Server 2009 references..


  2. Surya
    Oct 19, 2011 @ 15:44:24

    Do we need to provide TargetDir.


  3. muktadiur
    Jan 06, 2012 @ 10:56:18

    that’s work on debug mode but show the error on release mode and
    above command can’t delete the files.any solution for that?


  4. hint
    Jul 04, 2012 @ 15:21:26

    Add the Microsoft.SharePoint.Search.dll to your references and set Copy Local to false


  5. Ravi
    Mar 07, 2013 @ 11:43:41

    Great post, helped me for another relevant problem. And it was below ……
    Could not load file or assembly ‘Microsoft.SharePoint.Sandbox’ or one of its dependencies ..
    thanx !!


  6. lakshminarayana
    Oct 02, 2013 @ 19:45:21

    Thank You! My Problem Solved!
    But what is the impact of deleting this .dll post-build? Please clarify.


Leave a Comment

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Get every new post delivered to your Inbox.

Join 414 other followers

%d bloggers like this: