programing tip

빌드 오류 : "다른 프로세스에서 사용 중이므로 프로세스가 파일에 액세스 할 수 없습니다."

itbloger 2020. 10. 7. 07:24
반응형

빌드 오류 : "다른 프로세스에서 사용 중이므로 프로세스가 파일에 액세스 할 수 없습니다."


저는 C # webforms앱을 가지고 있는데 , 오늘까지 그냥 수영으로 작동했습니다.

이제 오늘 갑자기 앱을 실행하려고 할 때마다 파일 잠금 오류가 발생합니다.

"obj \ Debug \ MyProject.exe"파일을 "bin \ Debug \ MyProject.exe"에 복사 할 수 없습니다. 다른 프로세스에서 사용 중이므로 "bin \ Debug \ MyProject.exe"파일에 액세스 할 수 없습니다.

인터넷 검색 오류는 명백한 것 이상으로 나오지 않습니다. 즉, VS는 파일이 잠겨 있다고 생각합니다. 그리고 VS를 닫고 다시 열면 프로젝트가 처음으로 잘 실행되기 때문에 파일을 잠그는 것은 Visual Studio 자체입니다. 두 번째로 실행하려고하면 파일 잠금 오류가 발생합니다.

VS를 닫고 앱을 실행할 때마다 다시 여는 것은 실행 가능한 해결 방법이 아닙니다! 파일을 잠근 항목을 확인하고 파일이 잠기지 않도록하려면 어떻게합니까?

편집 : 또 다른 흥미로운 발견 : 앱을 실행할 필요조차 없습니다. 한 번만 컴파일하면 파일 잠금이 발생합니다. 두 번 연속 컴파일 할 수 없습니다!

이 문제는 내 솔루션의 한 프로젝트에만 해당됩니다. 다른 모든 프로젝트는 잘 작동하며 원하는만큼 여러 번 실행할 수 있습니다. 잠긴 것은이 하나의 프로젝트뿐입니다.


저에게 맞는 간단한 해결책을 찾았습니다. 다음과 같이 진행됩니다.

문제가 발생하면 맨 위에있는 건물 구성을 변경하고 (“Release”에서“Debug”로 또는 그 반대로) 빌드 한 다음 이전 구성으로 다시 변경하고 다시 빌드하십시오.

스크린 샷

구성을 변경하면 vcshost와 devenv가 해제된다고 가정합니다.


글쎄, 나는 문제를 직접 해결했다. 아직 이유는 모르겠지만. 프로젝트에서 모든 파일을 제거한 다음 다시 추가하고 어떤 파일이 문제의 원인인지 확인하여 문제를 격리하기로 결정했습니다. 그래서 하나씩 파일을 프로젝트에 다시 도입하고, 각 단계를 컴파일하고 정리했습니다 ... 때까지 ... 마지막 파일을 추가했습니다 ...

... 그리고 모든 것이 여전히 잘 작동했습니다.

원래 .csproj의 소스 컨트롤과 비교했습니다. 실제 차이는 없습니다. 그리고 .csproj의 이전 버전으로 되돌리려 고했지만 여전히 작동했습니다.

마법. 그것이 효과가 있다면 때로는 이유를 묻지 않는 것이 좋습니다. 그냥 받아들이고 계속 진행하십시오.

편집 : 문제는 되풀이되는 문제이며 컴파일 타임에 양식 디자이너가 추상 / 일반 양식을 열었을 때 문제를 분리했다고 생각합니다.

교훈 : 컴파일하기 전에 추상 또는 일반 양식 또는 컨트롤의 양식 디자이너가 닫혀 있는지 확인하십시오! 그렇지 않다면 VS를 닫고 다시 열어야합니다!


여기서 발견 한 내용은 다음과 같습니다. 프로젝트 속성 페이지의 디버그 탭에서 "Visual Studio 호스팅 프로세스 활성화"를 선택 취소합니다. 이 속성이 무엇인지 확실하지 않지만 한 번 확인하지 않으면 작업이 수행됩니다.


실제로 "Visual Studio 호스팅 프로세스 사용"을 선택해야합니다. 어쨌든 적어도 VS2010의 경우. 또한 다음이 있습니다.

존재하는 경우 "$ (TargetPath) .locked"del "$ (TargetPath) .locked"존재하는 경우 "$ (TargetPath)"존재하지 않는 경우 "$ (TargetPath) .locked"move "$ (TargetPath)" "$ (TargetPath) .locked "

사전 빌드 옵션에서. 이 문제는 오랫동안 저를 괴롭 혔습니다. John W.가이 확인란을 언급 할 때까지는이 확인란이 존재하고 낮다는 사실을 알아 차렸고 이미 선택 취소 된 것입니다.

또한 -app-vshost.exe는 디버깅하지 않을 때에도 백그라운드에서 실행됩니다. 이것이 내가 추측 할 때마다 성공적으로 빌드하고 실행하는 이유입니다. 이전에는 실행되지 않았습니다. 또한 디버그 및 릴리스 폴더를 정리하고 대상 유형을 지속적으로 변경하려고 시도했지만 위에서 설명한 것 외에는 아무것도 작동하지 않았습니다. 이전에 내 해결책은 빌드 사이에 5 분만 기다리는 것이 었는데, 작업을 완료하는 데 매우 성 가시고 시간이 많이 소요되었습니다. 나는 어떤 탭이 열려 있는지 또는 XNA 대 Windows가 형성되는지 또는 디자이너가 열리는지가 중요한 행동의 변화를 보지 못했습니다. 이 문제는 32 비트 또는 64 비트 빌드에서 발생했으며 ALT-F4로 앱을 종료했는지 또는 작업 관리자로 종료했는지 여부는 중요하지 않았습니다. 이론적으로는 앱이 리소스를 닫거나 해제 할 수 없습니다. 처음에는 쓰레기 수거 문제라고 생각했습니다.


조금 늦었지만 프로젝트 속성> "디버그"탭으로 이동하여 "Visual Studio 호스팅 프로세스 활성화"를 선택 취소하여이 문제를 해결합니다.


VS2017-Windows 작업 관리자에서 MSBuild.exe의 모든 인스턴스를 닫아 해결됨


Windows 탐색기를 사용하여 잠긴 파일의 이름을 변경하여이 문제를 극복했습니다. 파일을 삭제할 수 없었지만 잠긴 파일의 이름을 바꾸면 작동합니다!


bin \ Debug 폴더를 삭제하고 가능하면 VS를 다시 시작하여이 문제를 해결했습니다.


저에게는 설치되어 실행중인 Windows 서비스였습니다. 중지하면 빌드가 성공했습니다.


실행 상자에서 다음 명령을 실행합니다.

net stop iisadmin /y

그리고

iisreset

나를 위해 일했습니다. 2003 년 대비


참조를 확인하고 프로젝트에 대한 자체 참조를 제거하십시오.

설명 : 내 문제는 사용자 정의 제어를 작성하고 설계 양식에서 사용하기 위해 도구 상자 팔레트로 끌어서 놓은 후에 시작되었습니다. 처음에는 사용자 지정 제어 소스 파일 (.cs)과 프로젝트 실행 파일 (.exe) 사이에 중복이 있다는 경고가 나타났습니다. 실행 / 디버깅시 오류가 나타납니다. (.exe)가 사용되고 있기 때문에 액세스 할 수 없습니다 (그리고 사실임).

사용자 지정 컨트롤과 관련된 전체 소스 코드를 문자 그대로 제거했지만 참조를 확인하고 이전 사용자 지정 컨트롤을 "사용할 수 있도록"자체 참조 할 때까지 문제는 여전히 남아있었습니다. 참조를 제거하고 완료했습니다 !!


I had the same issue on my Xamarin application in visual studio and it was resolved by unplugging my test mobile device. The application was closed and the debugger was stopped but the error was still happening when trying to build or rebuild the solution. It only stopped after i unplugged the device because i had to receive a call.


Just to throw in my 2 cents. My issue was solved by opening Task Manager and killing the application. It was running in the background without any indication that it was running at all (no item in the task bar, no ui, nothing), but I am not sure why this happened. Obviously the debugger was not running and I only had a single instance of VS opened at the time. It amazes me that this is still happening in this VS 2017.

Perhaps I can add a build step that looks for the application running the background and kills it before starting the new one.


How is your web app configured? Does it run under Cassini (the tray web server) or IIS?

This shouldn't happen normally though. I think ProcessExplorer can tell you what files a process has locked. If not process explorer one of the other sysinternals tools.

One thing to try before even downloading one of the SI tools is to stop the Cassini web server, and seeing if that frees up the file.


What worked for me was restarting IIS


i had this same problem as well. changing the debug/release config didn't do the trick. at least not without building in between.

in my solution (winform) it was solved by opening the mainform of the winform in the designer. switching to code (F7). Then closing the code, closing the designer of the winform and rebuild all (ctrl-shift-B). This worked for me.

seems like some kind of handle from within the winform app (which runs a backgroundworker) still had a file handle on some of the other libraries used.


Recently ran into this problem when attempting to build a solution I am working on (not just a winforms proj).
In addition to build failure, I noticed that cleaning projects would quietly fail (checking the bin folder showed that the files had not actually been erased) and closing the Visual Studio did not end the devenv process - rather, it caused it to crash. Windows recovery process would then restart the Visual Studio.

After some trial and error, I found the problems only happened to me when I opened the solution from the "Recent" menu on starting up VS.
Opening the solution from File >> Open >> Project/Solution found it working as per usually.

Currently no idea why - will keep looking into this but for now, at least I can work!


I had two instances of Visual Studio opened the same solution.


In my case there were some vstest processes running (with various names but all containing the string vstest). I had to terminate them in taskmgr.


Same error, solved by updating Google Nuget support packages


When I ended the process .Net Core Host, everything built fine. I didn't have to close Visual Studio or do change anything else.


For those who are developing in VS with Docker, restart the docker for windows service and the problem will be solved immediately.

Before restarting docker I tried all the mentioned answers, didn't find a msbuild.exe process running, also tried restarting VS without avail, only restarting docker worked.


One more solution: when the files get locked, blocking process is reported (something like "ServiceHub.Host.CLR.x64 (7764)") with it's id in parentheses. To get rid of the process, open PowerShell (x + Win + I) and type: "Stop-Process -Id idNumber".


I recently ran into the issue when deploying to Service Fabric. The error is implying a 'file' is in use, however, I found that the port was being used by another IDE. By stopping a running service which was already hosting on the port, I was able to stop this exception from occurring.


I had the same issue and could not rectify by using any of the methods mentioned in previous answers. I resolved the issue by killing all instances of "SSIS Debug Hist (32 bit)" in task manager and now working as normal.


Had the same issue, so opened the task manager(as the error said it was being used by a process), there was my exe being run. I ended the task, it was back to normal after that

참고URL : https://stackoverflow.com/questions/5134137/build-error-the-process-cannot-access-the-file-because-it-is-being-used-by-ano

반응형