new_programmer
new_programmer

Reputation: 860

Could not load file or assembly Temporary ASP.NET Files

I am developing a website on ASP.NET in C# (.NET Framework 4). After creating a new website project I tried to run the project. But I am getting the below error:

Could not load file or assembly 'file:///C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\myfirst\159977c5\b9e740fc\App_global.asax.yfqtni9g.dll' or one of its dependencies. The system cannot find the file specified.

I already went through the below links [and all speaks about access to the folder], but it didn't help me :(

https://stackoverflow.com/questions/10496875/could-not-load-file-or-assembly-file-c-windows-microsoft-net-framework-v4-0

https://stackoverflow.com/questions/784157/asp-net-corrupt-assembly-could-not-load-file-or-assembly-app-web

http://web.archive.org/web/20101023213019/http://www.yetanotherdeveloper.com/post/2008/08/10/Could-not-load-file-or-assembly-App_Web.aspx

I checked and gave full access "Temporary ASP.NET Files" and to its sub folders and files for Users user-group.

Assembly Load Trace

WRN: Assembly binding logging is turned OFF. To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1. Note: There is some performance penalty associated with assembly bind failure logging. To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

Stack Trace

[FileNotFoundException: Could not load file or assembly 'file:///C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\myfirst\4ff7194b\2da62764\App_global.asax.h-eem9xt.dll' or one of its dependencies. The system cannot find the file specified.]
System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0
System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +39
System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection, Boolean suppressSecurityChecks) +132
System.Reflection.Assembly.Load(AssemblyName assemblyRef, Evidence assemblySecurity) +28
System.CodeDom.Compiler.CompilerResults.get_CompiledAssembly() +93
System.Web.Compilation.BuildProvider.CreateBuildResult(CompilerResults results) +60
System.Web.Compilation.BuildProvider.GetBuildResult(CompilerResults results) +16
System.Web.Compilation.ApplicationBuildProvider.GetGlobalAsaxBuildResult(Boolean isPrecompiledApp) +9118863
System.Web.Compilation.BuildManager.CompileGlobalAsax() +44
System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled() +265

[HttpException (0x80004005): Could not load file or assembly 'file:///C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\myfirst\4ff7194b\2da62764\App_global.asax.h-eem9xt.dll' or one of its dependencies. The system cannot find the file specified.]
System.Web.Compilation.BuildManager.ReportTopLevelCompilationException() +62
System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled() +421
System.Web.Compilation.BuildManager.CallAppInitializeMethod() +31
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +691

[HttpException (0x80004005): Could not load file or assembly 'file:///C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\myfirst\4ff7194b\2da62764\App_global.asax.h-eem9xt.dll' or one of its dependencies. The system cannot find the file specified.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9090876
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +97
System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr) +258

Please give me a link if this is a repeated question

Thanks in adv.

I got the Log as follows


The operation was successful.
Bind result: hr = 0x0. The operation completed successfully.

Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable  C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe
--- A detailed error log follows. 

=== Pre-bind state information ===
LOG: User = John-PC\John
LOG: DisplayName = Microsoft.VisualStudio.ComponentModelHost, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
 (Fully-specified)
LOG: Appbase = file:///G:/WorkShop/HTML-CSS/ASP/MyFirst/
LOG: Initial PrivatePath = G:\WorkShop\HTML-CSS\ASP\MyFirst\bin
LOG: Dynamic Base = C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\myfirst\159977c5
LOG: Cache Base = C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\myfirst\159977c5
LOG: AppName = b9e740fc
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: G:\WorkShop\HTML-CSS\ASP\MyFirst\web.config
LOG: Using host configuration file: 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Found assembly by looking in the GAC.
LOG: Binding succeeds. Returns assembly from C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Microsoft.VisualStudio.ComponentModelHost\v4.0_10.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.ComponentModelHost.dll.
LOG: Assembly is loaded in default load context.

I am not able to trace any error. Please help me....

Upvotes: 22

Views: 40175

Answers (12)

Anish Kutti
Anish Kutti

Reputation: 354

Removing contents inside <system.codedom> (web.config) block worked for me for a similar issue.

a) Following describe why you should remove it
What exactly does <system.codedom>/<compilers> do in web.config in MVC 5?

Following Additional article from microsoft helps understand the concept

https://learn.microsoft.com/en-us/previous-versions/ms366723(v=vs.140)?redirectedfrom=MSDN

Compilation Folder Location:

By default, when you compile a Web application the compiled code is placed in the Temporary ASP.NET Files folder. This folder is a subdirectory of the location where you installed the .NET framework

Besides this, another article suggested double-checking the targetFramework and framework installed

Upvotes: 1

Ali Eshghi
Ali Eshghi

Reputation: 1243

In my case, I locate the bin folder in web.config as follow :

<appSettings>
      <add key="webSettingFolder" value="C:\Users\ali eshghi\source\repos\SalesWebApiDotNetFramWork\SalesWebApiDotNetFramWork\bin\"/>
  </appSettings>

after that the error has vanished.

Upvotes: 0

Ahmed Siddiqui
Ahmed Siddiqui

Reputation: 31

Please backup and remove the folder myfirst\159977c5\b9e740fc\App_global.asax.yfqtni9g.dll'

Upvotes: 0

Zaif Ullah
Zaif Ullah

Reputation: 71

Remove the following lines from web.config will resolve your error.

<compilers>
      <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:1659;1699;1701" />
      <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+" />
    </compilers>
  </system.codedom>

Upvotes: 6

Shakoor Hussain Attari
Shakoor Hussain Attari

Reputation: 1821

removing temporary projects files in corresponding folder like for .net 4 from below folder will resolve the issue.

"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files"

also refer to this answer.

Answered by Tommy

Upvotes: 0

Anwar
Anwar

Reputation: 11

I had same problem. I just solve it by changing on web.config -> system.web -> compilation -> debug="false". Then it work fine

Upvotes: 0

Josh Mouch
Josh Mouch

Reputation: 3558

If you use Visual Studio Performance Tools then it is possible that Visual Studio left a key in your web.config appsettings section. It causes a 32 bit library to load, which won't work if your application is loading in 64 bit mode.

Check for the following and remove it:

<add key="Microsoft.VisualStudio.Enterprise.AspNetHelper.VsInstrLocation" value="C:\Program Files (x86)\Microsoft Visual Studio 11.0\Team Tools\Performance Tools\vsinstr.exe"/>

Upvotes: 9

Leniel Maccaferri
Leniel Maccaferri

Reputation: 102408

In my case while deploying an ASP.NET MVC project I renamed the DLL of one of the projects (the Assembly Name) in Visual Studio application properties.

Inside the Views folder of the ASP.NET MVC project sits a Web.config file. This Web.config file has the following razor section where we can list assemblies for nice IntelliSense support in Razor view files:

  <system.web.webPages.razor>
    <host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    <pages pageBaseType="System.Web.Mvc.WebViewPage">
      <namespaces>
        <add namespace="VizionLogs.LogRepository" />
        <add namespace="System.Web.Mvc" />
        <add namespace="System.Web.Mvc.Ajax" />
        <add namespace="System.Web.Mvc.Html" />
        <add namespace="System.Web.Optimization"/>
        <add namespace="System.Web.Routing" />
      </namespaces>
    </pages>
  </system.web.webPages.razor>

My problem: I renamed the project assembly from VizionLogs.LogRepository to ITVizion.VizionLogs.LogRepository and forgot to rename it in that Web.config file. This was causing that ASP.NET Temp folder error telling me it could not find VizionLogs.LogRepository. It took me some time to figure out what was going on and where the error was... :)

Upvotes: 2

Jan Remunda
Jan Remunda

Reputation: 7930

I had simmilar problem after i tried to start performance tests. I removed assemblyPostProcessorType attribute in system.web > compilation element in web.config and it worked again.

 <system.web>
<compilation debug="false" targetFramework="4.5.1"  
            assemblyPostProcessorType="Microsoft.VisualStudio.Enterprise.Common.AspPerformanceInstrumenter, Microsoft.VisualStudio.Enterprise.AspNetHelper, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</system.web>

Upvotes: 25

Sumant
Sumant

Reputation: 163

One of the solution is to delete those files from temporary asp.net folder that always works for me.

Upvotes: 4

Sarrus
Sarrus

Reputation: 631

Here you have similar problem I think: Could not load file or assembly 'file:///C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\ asp.net vs2010

accepted answer was:

Try performing a full solution build. If that doesn't work, click Build -> Clean Solution. If the error persists, delete everything in the C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\parktms folder and repeat.

Upvotes: 2

pero
pero

Reputation: 4259

Go to Registry and enter

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Fusion]
"EnableLog"=dword:00000001
"LogFailures"=dword:00000001
"LogPath"="c:\\temp\\fusionLog"

For loaded assembly you will find a log in c:\temp\fusionLog

There you will find what dependency is missing.

Upvotes: 1

Related Questions