Col
Col

Reputation: 656

Building a website project as 32-bit on a 64-bit build server

I have a VS 2010 solution that contains a website that has a web service within it. The web service references a COM dll that is causing problems when the solution is built on our 64-bit build server. I get the typical 32/64-bit error:

ASPNETCOMPILER : error ASPCONFIG: Could not load file or assembly 'xxx' or one of its dependencies. An attempt was made to load a program with an incorrect format

When I build the site using the 32-bit aspnet_compiler it builds okay. So, how do I specify that a website should be built as 32-bit? The Configuration Manager within VS will only let me choose Any CPU, so I cannot change it to x86 for this website...

Thanks.

Upvotes: 19

Views: 8908

Answers (6)

Nasser Hadjloo
Nasser Hadjloo

Reputation: 12610

You can use the following command. Actually, in this case you are using ASPNetCompiler x86 edition to build your own project

call "C:\Program Files\Microsoft Visual Studio 2008\VC\vcvarsall.bat" x86
MSBuild MySolutiuon.sln 

You can also use x86_amd64 for any cpu. Note that instead of using MSBuild you can load your confiiguration like

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
 <Target Name="PrecompileWeb">
     <AspNetCompiler
         VirtualPath="/MyWebSite"
         PhysicalPath="c:\inetpub\wwwroot\MyWebSite\"
         TargetPath="c:\precompiledweb\MyWebSite\"
         Force="true"
         Debug="true"
         FixedNames="True"
     />
 </Target>
</Project> 

to use above confiuguration you have to use

MSBuild your.xml /p:Configuration=Release

Upvotes: 8

johanvdw
johanvdw

Reputation: 421

Although this is an old question, I was faced with the same problem and I had some troubles finding an answer.

Visual studio offers two options for developing web applications: web sites and web applications. We applications generate assemblies per page, which are dynamically updated if the source changes. On the other hand web application projects are compiled in visual studio to one assembly. This assembly is not automatically rebuilt after changes to the source code. The differences are explained in detail in this document: http://msdn.microsoft.com/en-us/library/aa730880(VS.80).aspx#wapp_topic5

Another difference, which is relevant here is that web application projects allow you to actually choose an architecture contrary to web site projects. Converting a web site to a web application is not very hard, but not too straightforward (the option convert to web application is only available after creating a ... web application). Steps you can take:

  1. Create a new web empty web application
  2. Browse to the directory of new web application and copy all files from your website (overwriting anything in the directory)
  3. Add all files to the project
  4. Right click the project and choose “Convert to web application”.
  5. It may be needed to solve a few namespace issues.

Upvotes: 0

MikeTeeVee
MikeTeeVee

Reputation: 19392

Right-Click on your Web Project in Visual Studio.
Select "Properties".
Click the "Build" tab on the left.
Under "General" change the "Platform Target" to "x86" so it will always build for 32-bit.

Now when you do this you may notice on the same "Build" tab that the "Configuration" is set to "Active (Debug)". You will need to change that drop-down to all the different configuration settings you have (i.e. "Release", "QA", "Staging", "Demo", etc..) and make the same "Platform Target" change to "x86" for each one.

Don't forget to click the "Save" button when you're done - remember to set it back to "Debug" if you're on your development box.

That's probably why it only works when you build it on your machine, and not on the Build Server as the Build Server is most likely set up to build against a different configuration - which is correct, because you shouldn't be using the "Debug" configuration on a Build Server.

Upvotes: 0

musaul
musaul

Reputation: 2341

@Vilx, Check the dependency walker to find out how far it gets. My guess is it would probably stop at vjsnativ.dll. If that's as far as it gets, try this workaround.

Otherwise you'll have to chase down each DLL that the program can't find, and copy them into your program (or its bin) directory.

Upvotes: 1

Simon Mourier
Simon Mourier

Reputation: 138896

You need to use the ASP.NET Compilation Tool (Aspnet_compiler.exe). Look for the ' Finding the Correct Version of Aspnet_compiler.exe' chapter at the end of the doc, it explains how to find the 32 vs 64 bit versions of the tool.

Upvotes: 0

Madhur Ahuja
Madhur Ahuja

Reputation: 22681

Its not the compilation problem but the environment problem. The ASP.NET Website will always be built as Any CPU.

However, if you load it on 64 bit machine, by default 64 bit version of IIS is running which is unable to load COM DLL and it fails.

You need to configure IIS to run 32 bit applications on 64 bit Windows: http://www.microsoft.com/technet/prodtechnol/windowsserver2003/library/iis/405f5bb5-87a3-43d2-8138-54b75db73aa1.mspx

Upvotes: 0

Related Questions