1

I have a .Net Core 3.1 DLL project that all of a sudden didn't build anymore with the following error message:

CSC : error CS2012: Cannot open 'some.dll' for writing -- 'Access to the path 'some.dll' is denied.'

This project is not under any kind of source control. It's not on a build server (what most questions on Stack Overflow is about). It's a project on my local machine. Now, to rule out Visual Studio I've tried to build it from the command line with dotnet. Same thing unfortunately. Things I've tried:

This all didn't help. Then I had success for 1 build with:

  • Changing the target framework from 3.1 to 3.0
  • Changing the name of the project

This built the project once, because the filepath changes really, but then I got the same error the 2nd built.

Then I've had a few days success by:

  • Moving the entire solution to a new folder without the problematic project. Then adding a brand new project and adding the code to this complete new project.

But unfortunately after a few days I got the exact same problem. I have no idea what changed. It's always this project (which is a unittest project) and not the other project that it references (also a DLL project). I am out of ideas. Anybody have any suggestions for me to try?

Thanks in advance for helping.

Update My project's name = "TheGenesysProject.Engine.Test" and it was indeed quarantined by my company's security software as Pavel said in the comments. So I changed it to "JustSomeLib" and the security software didn't quarantine it anymore! Why this is, I have no clue whatsoever...

Update 2 it must be something in the project itself and not the name of the dll. I restored JustSomeLib so it had the same NuGet packages (xunit + xunit.runner.visualstudio) plus .cs files (just 3 files with some unittests in them nothing fancy) as TheGenesysProject.Engine.Test and it all build and worked once! Then I coded some more stuff. Added an unittest to test my new code and... Bam! In quarantine again. What the heck?! I am just logging this for if people have the same problem as I do.

Update 3 Just to conclude this story. The folder with sourcecode is now excluded from the malware scan and the dll's are not put in quarantine. This solved this problem. Thank you Pavel.

Danny van der Kraan
  • 5,344
  • 6
  • 31
  • 41
  • 2
    Your dll might be blocked by antivirus or firewall, faced with such behavior a few times. So, check your antivirus software and its quarantine – Pavel Anikhouski Oct 19 '20 at 10:10
  • 1
    @PavelAnikhouski You sir, are brilliant!! The company's firewall quarantined the dll every time I tried to build the project? To test this further I changed the name of my project from TheGenesysProject.Engine.Test to JustSomeLib and it worked! Why does it want to quarantine TheGenesysProject.Engine.Test though? I don't understand. Make a proper answer and I'll mark yours! – Danny van der Kraan Oct 19 '20 at 19:51
  • For me, the solution was to open Visual Studio by right-clicking and using "run as administrator" mode. Of course, you have to have Admin privileges to do that. Another possible solution is to make sure that an executable that uses the DLL isn't running in a process or a web browser. – JosephDoggie Sep 14 '22 at 16:27

0 Answers0