2

I've recently started learning how to make Powershell cmdlets with C# in Visual Studio. While attempting to build my Powershell cmdlets in Visual Studio 2013 I get this error. This forces me to close Powershell to build my code and then open Powershell again, which is pretty annoying. It most likely isn't the code's fault, as it does this even with an empty script. Does anyone know how to get around this problem? Thanks in advance for any advice.

The Powershell version is v3, with .NET 4. The version number shouldn't matter though, and I need these specific versions for this work.

1
  • 3
    This is normal behaviour. Since you are loading the dll file of the module in Powershell the file gets locked from modifying. Imagine what could and would happen if you delete or modify the module while powershell is running and you would try to use a function from it (crash). As a plus, you only need to close the instance of powershell that has your module loaded. Commented Jun 20, 2017 at 17:21

1 Answer 1

0

It does look like this is the intended purpose, thanks @bluuf. Looks like the best thing to do is start a new terminal like so:

powershell -NoExit -Command "<whatever you want to execute in the new shell> ; <you can do multiple like this>"

Then when you use

exit

It will close the shell that you imported with, leaving the original shell that you had to type the long command into up. Just hit the up arrow and that command pops up again ready to be reused. Far better than typing it out again.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.