SharePoint Internals – Hristo Pavlov’s Blog

6 June, 2008

Compiling SharePoint Solutions on 64bit

Filed under: SharePoint — Tags: , , — hristopavlov @ 3:33 am

Undoubtedly 64bit is the future of the software, however the transition from 32bit won’t be painless. As some of you may be thinking about moving to 64bit platform for SharePoint development or have already taken the plunge here are some lessons learned and frustrations from building SharePoint solutions on 64bit Windows 2003 using VS.NET 2005 + SP1 and Microsoft.NET Framework 2 + SP1 (32 and 62 bit)

1) First of all you should know that VS.NET 2005 is a 32 bit application. It will not work flawlessly on 64bit so be prepared that it will not behave. For example if you are running more than one instance of VS.NET in the same machine (even in different desktop sessions) sometimes it will just crash.

2) The Visual Studio 2005 extensions for Windows SharePoint Services 3.0 don’t have 64bit support at all, which means that you won’t be able to use any of the SharePoint projects for VS.NET in 64bit environment.

3) If you are building “ASP.NET Web Site” or “ASP.NET Web Service” then you may get this error:

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

If you just copy the 64bit version of Microsoft.SharePoint.Search.dll assembly from the SharePoint 2007 hive to your application BIN folder this will make the things even worse and you will start getting random errors. Some of them may be:

Attempted to load a 64-bit assembly on a 32-bit platform. Use ReflectionOnlyLoad() instead if trying to load for reflection purposes.  

There is a circular dependency in the target dependency graph involving target “Build”.

aspnet_compiler.exe” exited with code -2146233082.

Failed to create AppDomain.

Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

In order to solve the error you have to copy the 32bit version of the Microsoft.SharePoint.Search.dll (from a 32bit deployment of SharePoint) and copy it to your web site BIN folder as this is suggested in the following post.

A better solution could be to use an “ASP.NET Web Application” / “ASP.NET Web Service Application” projects instead of “ASP.NET Web Site” / “ASP.NET Web Service”. These project are available from File -> New -> Project -> Visual C#/VB.NET -> Web.

3 Comments »

  1. Hi,

    I’m currently running VS 2008 on Windows Server 2003 x64. We have ASP.NET Web App that depends on a class library that uses x64 Share Point assemblies. When we build our projects individually they compile fine. When we use a Web Deployment project(WDP) to build the ASP.NET Web App it fails b/c the WDP calls “C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe”. Which is the 32bit compiler vs. “C:\WINDOWS\Microsoft.NET\Framework64\v2.0.50727\aspnet_compiler.exe”. I think this situation is very close to what you are describing but not identical. We are compiling for “Any CPU” and all the referenced assemblies are to the 32bit versions b/c that is what is in the GAC. What did you do solve this issue with the second option above?

    Thanks,
    Ron

    Comment by Ron L — 3 July, 2008 @ 10:16 pm

  2. Hi Ron,

    Visual Studio is a 32 bit process. To my understanding it will always call the 32bit version of the aspnet_compiler in the Web Deployment Project. If you deploy your web site as source code, then IIS (a 64 bit process on the 64 bit windows) will call the 64bit version of the aspnet_compiler to compile your web site when built on the fly.

    The actual problem with the 32bit version of the aspnet_compiler crashing is because you are referencing 64bit versons of the SharePoint dlls. Try adding the 32bit references of the SharePoint dlls instead. This way your compiled solution will work just fine with the 64bit versions of the SharePoint dlls deployed to the server if you compile it using the AnyCPU mode.

    Hope this makes sense. I had to do this and also had to change the project type from “Web Site” to “Web Application” in order to resolve all compilation issues I’ve got.

    Comment by hristopavlov — 3 July, 2008 @ 11:31 pm

  3. A better solution is to use an “ASP.NET Web Site” instead of “ASP.NET Web Application” / “ASP.NET Web Service Application” project.

    How:

    1) – Open VS 2008 and Create a Blank Silution by selecting Other Project Types -> Visual Studio Solutions.

    2) – Now right click on Solution in Solution Explorer and click Add -> New Web Site…

    3) – Select ASP.NET Web Site template, if it is not already selected, choose Location and Language of your choice, for example select, in Location -> File Ssytem and C# in Language.

    Now you can add your required DLL as Reference. For examle Windows SharePoint Services for WSS 3.0 and enjoy.

    Comment by Syed Nasir Abbas — 8 April, 2011 @ 10:22 am


RSS feed for comments on this post. TrackBack URI

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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

Blog at WordPress.com.

%d bloggers like this: