IOException, lock on dll by other process
Hi, I don't really know how I to describe this but sometimes on reload, I have an IOException like this:
System.IO.IOException: The process cannot access the file 'C:\Users\nojaf\Projects\ronnies.be\src\server\bin\Debug\netcoreapp2.2\Ronnies.Server.dll' because it is being used by another process.
at System.IO.FileSystem.CopyFile(String sourceFullPath, String destFullPath, Boolean overwrite)
at System.IO.File.Copy(String sourceFileName, String destFileName, Boolean overwrite)
at FcsWatch.Binary.Extensions.Logger.CopyFile(Logger x, String src, String dest) in D:\Users\Jia\Downloads\FCSWatch-watch-content\FCSWatch-watch-content\src\FcsWatch.Binary\Extensions.fs:line 47
at FcsWatch.Binary.Extensions.SingleTargetCrackedFsproj.copyObjToBin[a](a configuration, SingleTargetCrackedFsproj singleTargetCrackedFsproj) in D:\Users\Jia\Downloads\FCSWatch-watch-content\FCSWatch-watch-content\src\FcsWatch.Binary\Extensions.fs:line 82
at FcsWatch.Binary.Extensions.CrackedFsproj.copyObjToBin@115-1.Invoke(SingleTargetCrackedFsproj singleTargetCrackedFsproj) in D:\Users\Jia\Downloads\FCSWatch-watch-content\FCSWatch-watch-content\src\FcsWatch.Binary\Extensions.fs:line 115
at Microsoft.FSharp.Primitives.Basics.List.iter[T](FSharpFunc`2 f, FSharpList`1 x)
at Microsoft.FSharp.Collections.ListModule.Iterate[T](FSharpFunc`2 action, FSharpList`1 list)
at FcsWatch.Binary.Extensions.CrackedFsproj.copyObjToBin[a](a configuration, CrackedFsproj crackedFsproj) in D:\Users\Jia\Downloads\FCSWatch-watch-content\FCSWatch-watch-content\src\FcsWatch.Binary\Extensions.fs:line 115
at FcsWatch.Binary.AutoReload.TmpEmitterStateModule.tryEmit@216-1.Invoke(String projPath) in D:\Users\Jia\Downloads\FCSWatch-watch-content\FCSWatch-watch-content\src\FcsWatch.Binary\AutoReload.fs:line 219
at Microsoft.FSharp.Collections.SeqModule.Iterate[T](FSharpFunc`2 action, IEnumerable`1 source)
at FcsWatch.Binary.AutoReload.TmpEmitterStateModule.tryEmit(ProgramRunningArgs args, CompilerTmpEmitterState`2 state) in D:\Users\Jia\Downloads\FCSWatch-watch-content\FCSWatch-watch-content\src\FcsWatch.Binary\AutoReload.fs:line 212
at FcsWatch.Binary.AutoReload.create@240.FcsWatch-Core-CompilerTmpEmitter-ICompilerTmpEmitter`3-TryEmit(String _arg1, CompilerTmpEmitterState`2 state) in D:\Users\Jia\Downloads\FCSWatch-watch-content\FCSWatch-watch-content\src\FcsWatch.Binary\AutoReload.fs:line 241
at [email protected](CompilerTmpEmitterMsg`2 _arg1) in D:\Users\Jia\Downloads\FCSWatch-watch-content\FCSWatch-watch-content\src\FcsWatch.Core\CompilerTmpEmitter.fs:line 176
at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvokeNoHijackCheck[a,b](AsyncActivation`1 ctxt, FSharpFunc`2 userCode, b result1)
at <StartupCode$FSharp-Core>[email protected](AsyncActivation`1 ctxt)
at [email protected](AsyncActivation`1 ctxt) in D:\Users\Jia\Downloads\FCSWatch-watch-content\FCSWatch-watch-content\src\FcsWatch.Core\CompilerTmpEmitter.fs:line 150
at <StartupCode$FSharp-Core>[email protected](AsyncActivation`1 ctxt)
at Microsoft.FSharp.Control.Trampoline.Execute(FSharpFunc`2 firstAction)
I'm using JetBrains Rider so that might have something to do with it. Other than that I think my project is a fairly standard aspnet core application. Is there anything I can do about this?
https://github.com/humhei/FCSWatch/blob/master/src/FcsWatch.Binary/AutoReload.fs#L219 https://github.com/humhei/FCSWatch/blob/master/src/FcsWatch.Binary/AutoReload.fs#L210
CrackedFsproj.tryKill args.DevelopmentTarget cache.EntryCrackedFsproj
Before copy dll from obj to bin, FcsWatch will try to kill the current project first. The asp.net core application should be killed
logger.InfoGreen "Killed process %d" proc.Id
@nojaf Can you try to set logger level to normal and see whether this line is printed?
Yes, this line is being printed
detect file C:\Users\nojaf\Projects\ronnies.be\src\server\Schema.fs changed
compilerTmpEmitter agent receive message IncrCompilingNum,current compiling number is 1
compilerTmpEmitter agent receive message AddTask,current compiling number is 1
Summary:
-- origin: C:\Users\nojaf\Projects\ronnies.be\src\server\Ronnies.Server.fsproj
-- dest: C:\Users\nojaf\Projects\ronnies.be\src\server\obj\Debug\netcoreapp2.2\Ronnies.Server.dll
-- elapsed: 1784 milliseconds
compilerTmpEmitter agent receive message AddTmp,current compiling number is 1
compilerTmpEmitter agent receive message DecrCompilingNum,current compiling number is 0
Current cached compier task is 2
Killed process 15992
System.IO.IOException: The process cannot access the file 'C:\Users\nojaf\Projects\ronnies.be\src\server\bin\Debug\netcoreapp2.2\Ronnies.Server.dll' because it is being used by another process.