开发者

Release Web Binary With Both 64 and 32bit support? ASP.NET

I would like to release my app with both 32 and 64bit support. I am using elmah and SQLite. Both packages have a separate binary for 32 and 64bits. I cant add both 32 and 64bit DLL. I tried adding both 32 & 64 bit DLLs with a different file开发者_JS百科name in my bin/release folder and i get an bad image format error. (I tested by running on a Windows server 64 bit with both DLLs in the directory and on my system which does 32bit).

How do i release the app so the same folder can be run as either 32bits or 64bits?


Having just fought with 32- vs. 64-bit not long ago, I'll take a shot at this, at least with some general observations. I know this question is over a year old, but I hope the answer helps someone anyway, regardless of whether you "accept" the answer (which, in contrast to some, is not why I answer questions on StackOverflow).

First off, will 32-bit-only work in a WOW64 context in your situation? Often it will, and that can simplify your situation.

There are, however, situations in which third-party libraries make WOW64 not workable, at least according to their documentation, which is the situation I was facing. To solve the problem, I had to have both a 32-bit and a 64-bit build. If there is a way to release them both in the "same folders" somehow, I did not find it. However, it really was not too difficult to do so. I did have to edit the Visual Studio project files by hand. If I recall, the basic steps were:

  1. Set up my build definitions in Visual Studio carefully, so that both release and debug versions had individual projects set correctly. That meant, in my case, that anything interacting with the native libraries at all had to be built in either x86 or x64 format, not Any CPU. Projects that are MSIL-only can be Any CPU, as far as I can tell.
  2. Edit your project files (e.g., .csproj) so that the correct third-party DLLs are put in the correct folders based on the build. If there was an easier way to accomplish this, I didn't see it. There may be an obvious project file within your solution for this to happen, though it can really happen anywhere in your solution, so long as:
  3. In your actual web project, make sure you add the project with the third-party DLL copy as a reference, even if the web project does not use this other project directly. That way, the files will get copied to your build directory. This seems like a bug in either MSBuild or Visual Studio to me, but as of VS2010, it does not seem to have been fixed. Also, if you need to copy the third-party DLLs to a directory such as App_Code, you may need to edit the web project file to accomplish that.

I would have to be at work to look at the project files and see what changes I specifically made, but these were the basic steps. Unless you can get away with your entire project being compiled as Any CPU, I think you will need to compile both a 32-bit and 64-bit version and deploy the one you need. Your actual code likely will not change, unless you are using native or unmanaged code.

Someone may come along who knows more about this than I, but I hope this helps someone. I'll try to answer any questions left in the comments.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜