Closed nickelnext closed 7 years ago
It could be that that the worker process running the old instance has the file locked. You could use ProcMon to see what has it locked.
It might be possible to change ERVPP to load a shadow copied assembly or something, not sure.
What might be easier would be to prevent the locking. E.g. Stop worker process before deploy, use app-offline.htm, or deploy the new code to a different folder.
On Thu, 9 Mar 2017 at 08:43, nickelnext notifications@github.com wrote:
Hello again my friend we just upgraded from 1.3.23 to 1.3.48 and still we experience this
Solution:
- Core (with base css, js and cshtml files) proj
- Specific (overrides some css, js or cshtml files) proj
Our Homepage loads content from both Specific and Core projs, thanks to VPP.
Once i try to login, the page suddendly becomes white and i get this error in eventlog.xml
`IIS APPPOOL\SpecificProjPathConfigurationErrorsExceptionCould not load file or assembly 'CoreProj' or one of its dependencies. The process cannot access the file because it is being used by another process. (Exception from HRESULT: 0x80070020) at System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) at System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() at System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) at System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) at System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies() at System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) at System.Web.Compilation.BuildManager.ExecutePreAppStart() at System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException)
Could not load file or assembly 'CoreProj' or one of its dependencies. The process cannot access the file because it is being used by another process. (Exception from HRESULT: 0x80070020) at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) at System.Reflection.Assembly.Load(String assemblyString) at System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective)
`
This happens only sometimes after publishing. Do you think it has something to do with you library?
Thanks
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/mcintyre321/EmbeddedResourceVirtualPathProvider/issues/34, or mute the thread https://github.com/notifications/unsubscribe-auth/AAQ0-k7bJ26jjZ4kmnWK_LXlybfiZFWjks5rj7utgaJpZM4MXysX .
hi mcintyre321
For what i read online,
System.Web.Compilation.BuildManager.GetReferencedAssemblies()
.Cast<Assembly>()
already adds shadow copying to the loading assembly, doesn't it?
Or you mean the loading of the assembly that the VPP does inside your code?
I'm afraid I'm not sure what the problem is. I think careful use of ProcMon and monitoring which PID (process IDs) access the dlls is how I would diagnose.
Since i'm using an Azure App Service resource, the only processes i see thru the Process Explorer are the w3wp ones of IIS. I can't see any other process.
This only happens on azure while when debugging on my machine it works perfectly.
This is very frustrating :/
Does it happen every request, or just once, after publish?
Does killing the w3wp fix it?
Killing w3wp doesn't fix it.
Now it's happening at every request.
If i look at the homepage (no owin involved) the page get shown correctly. If i login and try to access any page that requires authentication (MVC auth, owin i mean) it doesn't work.
Funny thing is, the API work perfectly (even the endpoints for logging in/out or that do require bearer auth)
Does the homepage use any embedded resources?
The homepage as well as every other page uses embedded resources, your VPP. So yes
I resolved. One error was given by a nullreference exception i didn't see in the log file.
The second error, related to the topic, i solved by writing this in Start() `
var x = AppDomain.CurrentDomain.GetAssemblies();
Assembly mine = x.Where(a => a.GetName().Name == "Live.Server.Core").FirstOrDefault();
System.Web.Hosting.HostingEnvironment.RegisterVirtualPathProvider(new EmbeddedResourceVirtualPathProvider.Vpp(mine)
{
//you can do a specific assembly registration too. If you provide the assemly source path, it can read
//from the source file so you can change the content while the app is running without needing to rebuild
//{typeof(SomeAssembly.SomeClass).Assembly, @"..\SomeAssembly"}
});`
Now i don't get the lock anymore.
Last question my friend:
What does your comment mean? It's not clear to me what "you can change the content while the app is running without needing to rebuild" means. If my files are inside a DLL i either recompile the dll or how am i supposed to see the resources?
Cheers
Glad you found the solution - I'm not 100% sure I understand the problem from your explanation though. Is it something other users of ERVPP are likely to run into? Is there a change I should make to prevent it happening to others?
My comment is referring to live editing while you are working locally, and want to make changes to a view while debugging. The second parameter is the path to the folder containing the source files. If you provide it, then the ERVPP uses the source files rather than the embedded resources in the dll (which are locked once you start debugging)
Basically in my eventlog.xml file on the server sometimes i was reading an error saying the resource "Core Proj" was locked.
I changed the way of loading the assemblies, from yours (using getReferencedAssemblies()) to mine (using appdomain.currendomain.getassemblies()) and now i don't get that error anymore.
If anyone else is going to get the same error, they should try to change the code in Start() from yours to mine. That's my experience.
The fact that my page was completely blank, though, was due to an error in one of the views, which was not showing up as a NullReferenceException. While changing the code of my view i realized it was possibile i was getting a NRE and by changing it, the page went back on working.
Thanks!
Ah, gotcha. Think the reason I use getReferencedAssemblies is that it loads assemblies which haven't been brought into the current app domain yet, so it will work out of the box even if the code runs before anything else.
Hello again my friend we just upgraded from 1.3.23 to 1.3.48 and still we experience this
Solution:
Our Homepage loads content from both Specific and Core projs, thanks to VPP.
Once i try to login, the page suddendly becomes white and i get this error in eventlog.xml
`IIS APPPOOL\SpecificProjPathConfigurationErrorsExceptionCould not load file or assembly 'CoreProj' or one of its dependencies. The process cannot access the file because it is being used by another process. (Exception from HRESULT: 0x80070020) at System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) at System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() at System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) at System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) at System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies() at System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) at System.Web.Compilation.BuildManager.ExecutePreAppStart() at System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException)
Could not load file or assembly 'CoreProj' or one of its dependencies. The process cannot access the file because it is being used by another process. (Exception from HRESULT: 0x80070020) at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) at System.Reflection.Assembly.Load(String assemblyString) at System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective)
`
This happens only sometimes after publishing. Do you think it has something to do with you library?
Thanks