Search code examples
c#azureasp.net-mvc-5

Auto Generated File in temp directory causing errors while Publishing


I am trying to publish my code but every time this error comes up. couldn't figure out the problem causing this . I am using vs2019.

C:\Users\user\AppData\Local\Temp\Temporary ASP.NET Files\root\3ae3db50\386f86a2\App_Web_ysujl3yj.1.cs(34,0): Error CS0246: The type or namespace name 'MediaTypeHeaderValue' could not be found (are you missing a using directive or an assembly reference?)

Am I missing any package or reference ? Has anyone encountered this error before? Is it related to IIS? P.S: While debugging it runs smoothly and not showed any error or exception.

Updated: Error List Shows this

but Unbale to find this file in my project.


Solution

  • You can try:

    • Clean solution then rebuild it.
    • Go to Solution Explorer. Right click on Solution. Go to Properties. Go to Configuration Manager. Check if the checkboxes under Build are checked or not. If any or all of them are unchecked, then check them and try build the solution again.
    • Remove the project reference and then adding it back in again, and check if all those missing dll file exists in the bin folder.
    • Delete bin/obj folder, build again and try to restart Visual Studio.

    Some times we might miss **using ** keyword.

    For further details refer SO-Thread1, SO-Thread2.