Type 'MYCLASS' exists in both 'PROJECT' and 'App_Code'

I have created a Web Forms application. In this application, I have a class named 'MYCLASS' located in the App_code folder. In the main project called PROJECTNAME, I have a webhandler named SignForm.ashx. In it, it references a function from my class MYCLASS. Yet for some reason, it marks it as red claiming:

"The type 'MYCLASS' exists in btoh 'PROJECTNAME, Version = 1.0.0.0, Culture=neutral, PublicKeyToken=null' and 'App_Code.7_pcboji, Version =0.0.0.0, Culture=neutral, PublicKeyToken=null'".

Why is it doing this? I have already tried the following solutions based on what I found on Stack Overflow:

  1. Clean the solution.
  2. Rebuild the solution.
  3. Clear Temporary ASP.NET files
  4. Go to Web.config and set batch="false" in the section.
  5. Yes, I have seen the whole "change the App_Code folder to something else" solution (like Code), but I don't want to do this since a similar application I have is working without making this change.

Also of note: I didn't have this problem before when I created a generic web handler. The issue for me was that it was creating a .ashx file that was implemented by a ashx.cs file (I wanted everything in the .ashx file). When I referenced my class here, it did not give me the above error. However, as soon as I deleted the ashx.cs file and put everything in that .ashx file, that's when the problem started.

Again, what is going on with this and how can I resolve it?

1 answer

  • answered 2018-10-10 07:49 Tareq

    Sometimes this problem appears when you rename the project so you will have two dlls in the bin folder (oldProject.dll and newProject.dll) and this will cause such a problem.