I've just started working on an ASPNET project running in 4.6.2. Code downloads, builds and runs fine (VS2019 community) but I am getting a ton of warnings like this:

CS0436 The type 'UserModel' in '...\Crm\App_Code\Models\UserModel.cs' conflicts with the imported type 'UserModel' in 'Crm, Version=, Culture=neutral, PublicKeyToken=null'. Using the type defined in '...\Crm\App_Code\Models\UserModel.cs'.

Can't understand how this reference is duplicating itself. This is a type defined one time in my codebase. There is only one single build assembly. There are no duplicate declarations (as in this post ). Its like somehow the project is referencing its own built assembly and getting confused. Is this some weird ASPNET magic going on here?

Interestingly, if I build it in VS2017 professional, these show up as CS0012 errors, but don't prevent the project from building or running.

Can somebody help either just understand what is happening or better yet, clear these warnings/errors?

1 Answers

Alfredo Revilla On Best Solutions

App_Code should not be used in Web Applications projects. You will get 2 assemblies containing the same types, one in bin and one in asp.net temporary files (this by IIS itself). Just rename the folder (git mv or similar) and rebuild to validate references.