可以再次删除PowerShell中的添加类型吗? [英] Can you remove an Add-ed Type in PowerShell again?

查看:225
本文介绍了可以再次删除PowerShell中的添加类型吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在C#中编写一个库,并在某些场合使用PowerShell快速测试。然而,这样可以防止我重新构建项目,因为PowerShell显然仍然有DLL打开。

I'm currently writing a library in C# and was using PowerShell to quickly test it on some occasions. However, this prevents me from re-building the project as PowerShell obviously still has the DLL open.

有没有一种方式再次卸载该DLL与code>添加型?该文档似乎没有线索,明显的候选人将是删除类型(不存在 - 只有一个命令无论如何键入作为其名词)。关闭PowerShell并执行导航到构建目录的所有东西,并在每次重建时再次添加类型,这样会变得很麻烦。

Is there a way of unloading the DLL again after adding it with Add-Type? The documentation doesn't seem to have clues on that and the obvious candidate would be Remove-Type (which doesn't exist – there is only one command anyway with Type as its noun). It gets cumbersome to close PowerShell and do all the stuff of navigating to the build directory and adding the type again each time I want to rebuild.

推荐答案

像其他人一样,这是一个.NET行为。加载到AppDomain中的程序集不能卸载。只有AppDomain可以卸载,而PowerShell使用单个appdomain。几年前,我发表了一些关于这一点的消息: http://www.nivot.org /2007/12/07/WhyAppDomainsAreNotAMagicBullet.aspx

Like the others say, this is a .NET behavior. Assemblies loaded into an AppDomain cannot be unloaded. Only the AppDomain can be unloaded, and powershell uses a single appdomain. I blogged a bit about this some years ago: http://www.nivot.org/2007/12/07/WhyAppDomainsAreNotAMagicBullet.aspx

当我这样测试时,我通常会保持一个shell打开,并使用一个嵌套shell进行测试。启动powerhell,cd到bin位置,然后运行powershell启动嵌套shell(新进程)exit重新开始,再次运行powershell。

When I test like this, I usually keep a shell open and use a nested shell to do tests. start powershell, cd to bin location then run "powershell" to start nested shell (new process.) "exit" to start over, and run "powershell" again.

这篇关于可以再次删除PowerShell中的添加类型吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆