3

Background: We have old-style ASP.NET WSP - web site project. This is the one that does not produces single DLL and uses dll.refresh files for reference mappings.

Problem: Using VS2017, we're able to work with it with no issues but only as long as DLLs we reference are not x64. See pictures below

With x64 DLLs When x64 DLLs are in reference, the reference is NOT listed

With x86 DLLs When x86 DLLs are in reference, the reference IS listed

As result, in code files we get suggestions to "add reference". This type of "project" is regulated in large by web.config. But I couldn't find any switch that would help. I also turned on "Use 64-bit IIS" in tools but no help.

What do we know

  • This is a design time issue
  • If I use Aspnet_compiler against this WSP with x64 dependencies, it compiles fine
  • On Dev box I can use x86 dependencies and work in this way (and have been for 18 years). But on build box we need x64 DLLs. ++ This one demands explanation. We used to only precompile (aspnet_compiler) for release. But now, we also want to build and validate before precompilation. Precompilation without validation has couple drawbacks - it doesn't validate ashx handlers and it doesn't pull dependencies - we have to know which DLLs to supply and then it will compile.

It seem to me that somehow I need to tell Visual Studio to use 64-bit tools, but I don't know how. For projects with project files there is <AspNetToolPath> tag. But how to replicate this here? When I build with MSBUILD it gives me ASPNETCOMPILER : error ASPCONFIG: Could not load file or assembly... incorrect format. So, there is something with wrong toolset and in VS background compilation is not working. And same with MSBuild - it picks wrong toolset, or, it picks whatever toolset is should but I need to give command which to use.

T.S.
  • 18,195
  • 11
  • 58
  • 78
  • Is this really the answer? - https://stackoverflow.com/a/2950664/1704458 – T.S. Jul 29 '19 at 18:44
  • Have you ever got this working? I've ran into the exact same problem where I want to use a 64bit DLL in an old Web Site Project :( – Landcross Oct 16 '19 at 08:45
  • 1
    @Landcross Thank you for reminding this to me. Yes! I had communication with Microsoft specialists and they gave me the answer I just posted below. – T.S. Oct 16 '19 at 13:15

1 Answers1

4

This is official answer I've got from Microsoft

...unfortunately Visual Studio does not have good support for 64 bit assemblies for website projects. In general, this is because Visual Studio and an external process used for Asp.Net intellisense are 32bit applications and thus cannot load these assemblies. However, since this is a website the build will happen on the server when the page is requested. Because of this, and in general to improve the F5 inner-loop, you can turn off the build in VS - it is only used for validation purposes anyway. To do this:

  • right-click on Project node and choose Property Pages

  • On the Build tab change the Before running startup page option to "No build", and uncheck the Build web site as part of solution

Doing this means you will not see build errors in the IDE, instead they will appear in the browser when you browse to the affected page. And intellisense will not be accurate since types from the 64 bit assemblies will not be recognized.

T.S.
  • 18,195
  • 11
  • 58
  • 78
  • 1
    That's a bummer :( That doesn't sound like an ideal solution. In any case, thanks for posting the answer. – Landcross Oct 21 '19 at 07:15
  • 1
    @Landcross The "ideal" solution that we use: we use x86 and AnyCpu third party components during design/debug time. We precompile our website using x64 (this is optional but lets you verify integrity during build time). + precompile means faster loads on deployment servers. Generally, we're trying to have all components AnyCpu but some third parties provide only x86/x64, which might change soon – T.S. Oct 21 '19 at 15:33
  • 1
    Yeah, that sounds reasonable when 32 and 64 bit dll files are available. The thing is, I want/need to use a third-party package that (nowadays) only provides a 64 bit version... – Landcross Oct 21 '19 at 17:09
  • @Landcross wow! this is horrible. Can you contact them and ask for AnyCPU version ? If there is really not a lot in it, you can reflect and build your own version, or create wrappers – T.S. Oct 21 '19 at 18:56
  • 1
    It's the open-source Google OR tools, I don't think they'll be releasing a 32 bit version anymore since as far as I understand it they deprecated that a while ago. Maybe I can build a 32 bit version myself from source, but not sure if that'll work, haven't tried that yet. It doesn't help that I'm not that experienced with .NET (and the last time I used it was a few years ago) haha. – Landcross Oct 22 '19 at 08:45
  • This **solution** might help you: https://stackoverflow.com/a/30851524/9258504 – SamBerk Sep 05 '21 at 18:53
  • @SamBerk You're mixing design time and runtime – T.S. Sep 13 '21 at 21:44