asp.net.netvisual-studiovs-web-site-projectaspnet-compiler

Using 64-bit references in ASP.NET Web Site Project - design time issues


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

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.


Solution

  • 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:

    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.