Compilation Error: The type 'ASP.global_asax' exists in both DLLs

49,776

Solution 1

In my case the problem occurred in a virtual application's bin folder. Looking into this bin-folder you will probably see two files (an information I found here):

  • App_global.asax.dll
  • App_global.asax.compiled

Removing these resolves the error. The App_global.asax.dll is generated at runtime too which causes the problem. I am however still investigating how these files got there, so comments are definitely welcome!

Solution 2

I suggest you go to the path: C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files and clear the all the temporary files of your application, build your solution, and then run it!

Solution 3

In my case the problem was caused by accidentional removal of "PrecompiledApp.config". As soon as i returned the file everything started working normally.

Solution 4

I struggled with this issue in .NET 4.5 in VS2013 for a while before finding a solution that worked:

  • Manually deleting the contents of the ASP.Net project's bin-folder. Clean/Rebuild was insufficient. It didn't delete enough apparently ;)

The error persisted after adding the batch="false"attribute in the compilation-element of web.config.

It also did not help to delete the ASP.Net Temporary Files-directory either.

Solution 5

In my case, i have added in my folder bin a file with name "App_global.asax.compiled" delete only this files and its work.

View Image

Share:
49,776

Related videos on Youtube

KomalJariwala
Author by

KomalJariwala

I am passionate ASP.NET C# Developer, Working in MVC5 and EF application having 1.5 years of experience.

Updated on July 08, 2022

Comments

  • KomalJariwala
    KomalJariwala almost 2 years

    I have just integrated another project pages and its dlls into my existing project's Bin/ folder. My project framework is 3.5. When i am trying to build the project or solution, it's throwing following error:

    "The type 'ASP.global_asax' exists in both 'c:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\timesheet\15a75c54\898b48b9\assembly\dl3\58b062b2\00ceda54_c98cc801\App_global.asax.DLL' and 'c:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\timesheet\15a75c54\898b48b9\App_global.asax.q_h6dbfx.dll' c:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\timesheet\15a75c54\898b48b9\App_Web_admin.master.fdf7a39c.zecazgwd.0.cs "

    Setting "batch=false" into web.config's is not working. I have also tried to delete all folders from "c:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\", then clean and rebuild soultion. But still it's not working.

  • BornToCode
    BornToCode almost 10 years
    A way how these files could get there is if in one of your deployments your publish settings included the setting 'Precompile during publishing'
  • Alessandro
    Alessandro over 9 years
    @BornToCode You saved my day!! :)
  • Chris Nevill
    Chris Nevill almost 9 years
    In my case the Precompile during publishing option was already turned off. After deleting the files they didn't come back and the website started working again. Turning the 'Precompile' on caused the files to be generated... but the website then continued to work?!
  • Morten Jensen
    Morten Jensen over 8 years
    As far as I can see, the author has tried this and it doesn't work. FWIW I have the same problem as the OP and deleting temp-files doesn't work, neither does setting batch=false in web.config
  • MarceloBarbosa
    MarceloBarbosa over 7 years
    Weeeeee! Thank you!
  • Joe 89
    Joe 89 over 7 years
    After publishing using "Precompile" turned on solved this problem
  • M2012
    M2012 almost 7 years
    I've same problem, I removed app_global.asax.dll file from the bin. But how these files got in bin.
  • Tahir Alvi
    Tahir Alvi almost 7 years
    Thanks its works for me, before that i am struggling to fix this issue on azure environment.
  • Anders Kjeldsen
    Anders Kjeldsen over 6 years
    Could it be because PrecompiledApp.config is missing?
  • Moslem Hadi
    Moslem Hadi over 6 years
    I had these files in Bin folder and a 'global.asax' file in root folder. I just deleted these files and problem solved! tnx.
  • Admin
    Admin about 6 years
    If by doing all these, you're still having the same issue, look at the references of your project. You might have a reference to that problematic dll which you need to remove. (Mine was a reference to App_Web_506b2eef.y07ibuiq)
  • Uwe Keim
    Uwe Keim about 6 years
    Is this an error description or a solution description?
  • Muhammad Bilal
    Muhammad Bilal about 6 years
    Its solutions, Make sure you have added PrecompiledApp.config on root staging as well
  • more urgent jest
    more urgent jest about 4 years
    this worked for me as well, whereas deleting the temp folder didn't