How can I check if a string is null or empty in PowerShell?

Is there a built-in IsNullOrEmpty -like function in order to check if a string is null or empty, in PowerShell? I could not find it so far and if there is a built-in way, I do not want to write a function for this. 您可以使用IsNullOrEmpty静态方法: [string]::IsNullOrEmpty(...) You guys are making this too hard. PowerShell handles this quite elegantly eg: > $str1 = $null > if ($str1) {

如何在PowerShell中检查字符串是否为空或空?

在PowerShell中,是否有内置的IsNullOrEmpty类函数来检查字符串是空还是空? 到目前为止我找不到它,如果有内置的方式,我不想为此写一个函数。 您可以使用IsNullOrEmpty静态方法: [string]::IsNullOrEmpty(...) 你们这样做太难了。 PowerShell可以很好地处理这个问题,例如: > $str1 = $null > if ($str1) { 'not empty' } else { 'empty' } empty > $str2 = '' > if ($str2) { 'not empty' } else { 'empt

Why doesn't Edit and Continue work on the x64 CLR?

Microsoft have explained that they won't be supporting Edit and Continue under the x64 CLR in Visual Studio 2010: When creating a new Visual C# Console Application in VS2010 for .NET 4.0, the default target settings for the project is to target the x86 platform instead of Any CPU (MSIL) like Visual Studio 2008 does [...] Adding true support for EnC to the 64-bit CLR is unfortunately a l

为什么不编辑并继续在x64 CLR上工作?

微软已经解释说,他们不会支持Visual Studio 2010中x64 CLR下的编辑和继续: 当在VS2010中为.NET 4.0创建一个新的Visual C#控制台应用程序时,该项目的默认目标设置是针对x86平台而不是像Visual Studio 2008那样的任何CPU(MSIL) [...] 不幸的是,为EnC增加对64位CLR的真正支持是一个很大的工作项目,其他功能的优先顺序是考虑到将平台目标更改为x86的工作。 (来自http://connect.microsoft.com/VisualStudio/feedbac

Minimum version of .NET 2.0 framework to support Powershell 2.0?

Background: I had a build machine with .NET 2.0 SP1 (and no higher) which uses msbuild and powershell for its build; unfortunately, workstations cannot load the binaries built on this machine, unless .NET 2.0 SP2 is installed. To fix this I'm creating a build machine with minimum specs; the most important one being .NET 2.0 SP1. If I install Powershell 2.0, is there a good chance that I

.NET 2.0框架的最低版本支持Powershell 2.0?

背景:我有一台使用.NET 2.0 SP1的构建机器(不会更高),它使用msbuild和powershell构建; 不幸的是,除非安装了.NET 2.0 SP2,否则工作站无法加载构建在此机器上的二进制文件。 为了解决这个问题,我创建了一个具有最小规格的构建机器; 最重要的是.NET 2.0 SP1。 如果我安装Powershell 2.0,是否有很好的机会介绍更高版本的.NET Framework的依赖关系? 您可以阅读Windows Management Framework(Windows PowerShell 2.0

How do I find the .NET version?

How do I find out which version of .NET is installed? I'm looking for something as simple as "java -version" that I can type at the command prompt and that tells me the current version(s) installed. I better add that Visual Studio may not be installed - this is typically something that I want to know about a client machine. Just type any one of the below commands to give you t

我如何找到.NET版本?

如何找出安装了哪个版本的.NET? 我正在寻找一些简单的“java -version”,我可以在命令提示符下输入,并告诉我当前安装的版本。 我更好地补充说,Visual Studio可能不会被安装 - 这通常是我想知道的关于客户端机器的事情。 只需键入以下任一命令即可在第一行中为您提供最新版本。 1. CSC 2. GACUTIL /l ? 3. CLRVER 如果您安装了Visual Studio,则只能从Visual Studio命令提示符运行这些命令,否则如果您具有.NET框架SDK

.NET Framework version issue

I am using IIS 7.0 + Windows Server 2008 x64. I have installed .NET Framework 3.5 on my machine, but from the IIS 7.0 application pool .NET framework settings, I could only set version to v1.0 or v2.0. Why can't I set to version v3.5 -- which is the latest version of .NET framework I installed on my machine? To answer the comment that George2 has left to each of the other answers in one p

.NET Framework版本问题

我正在使用IIS 7.0 + Windows Server 2008 x64。 我在我的机器上安装了.NET Framework 3.5,但是从IIS 7.0应用程序池.NET框架设置中,我只能将版本设置为v1.0或v2.0。 为什么我不能设置为v3.5版本 - 这是我在我的机器上安装的最新版本的.NET框架? 为了回答George2在一个地方留给其他答案的评论: 是。 通用语言运行时间是需要2.0(目前不能更高,因为这是目前最新的版本)。 是。 如果使.NET Framework更容易,您可以

Mixed mode assembly is built against version ‘v2.0.50727′ of the runtime

I'm getting the following exception: Mixed mode assembly is built against version 'v2.0.50727′ of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information. as I was trying to export crystal report from my WPF program... I have added the following in the app.config already... <startup useLegacyV2RuntimeActivationPolicy="true"> <supp

混合模式程序集是针对运行时版本“v2.0.50727”构建的

我收到以下例外情况: 混合模式程序集是针对运行时版本“v2.0.50727”构建的,无需其他配置信息即可在4.0运行时加载。 因为我试图从我的WPF程序中导出水晶报告...... 我已经在app.config中添加了以下内容... <startup useLegacyV2RuntimeActivationPolicy="true"> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/> </startup> <runtime> <NetFx40_LegacySecurityPolicy

Application Crashes With "Internal Error In The .NET Runtime"

We have an application written against .NET 4.0 which over the weekend crashed, putting the following message into the event log: Application: PnrRetrieverService.exe Framework Version: v4.0.30319 Description: The process was terminated due to an internal error in the .NET Runtime at IP 791F9AAA (79140000) with exit code 80131506. This is on a Windows Server 2003 R2 Standard Edition box. G

“.NET运行时内部错误”导致应用程序崩溃

我们有一个针对.NET 4.0编写的应用程序,周末崩溃,将以下消息放入事件日志中: 应用程序:PnrRetrieverService.exe框架版本:v4.0.30319 说明:由于.NET运行时中的IP 791F9AAA(79140000)的退出代码为80131506的内部错误,进程已终止。 这是在Windows Server 2003 R2标准版盒子上。 谷歌搜索这个错误没有发现任何相关。 例如,这不是在VS Studio中发生的,而是在生产箱中发生的; 当服务最终重新启动时,它没有遇到更

What does 'useLegacyV2RuntimeActivationPolicy' do in the .NET 4 config?

While converting a project that used SlimDX, and therefore has unmanaged code, to .NET 4.0 I ran into the following error: Mixed mode assembly is built against version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information. Googling around gave me the solution, which is to add this to the applications config: <configuration

'useLegacyV2RuntimeActivationPolicy'在.NET 4配置中做了什么?

在将使用SlimDX并因此具有非托管代码的项目转换为.NET 4.0时,我遇到了以下错误: 混合模式程序集是针对运行时版本“v2.0.50727”构建的,无需其他配置信息即可在4.0运行时加载。 谷歌搜索给我的解决方案,这是添加到应用程序配置: <configuration> <startup useLegacyV2RuntimeActivationPolicy="true"> <supportedRuntime version="v4.0"/> </startup> </configuration> 我的问题

How to Chain Commands at a Special PowerShell 4 Command Prompt?

Normally, PowerShell commands can be chained with semicolons. The following opens 2 notepads: PS> notepad; notepad You can also chain a more complex statement: PS> Add-Type -AssemblyName System.IO.Compression; ` > $src = "C:aFolder"; $zip="C:my.zip"; ` > [io.compression.zipfile]::CreateFromDirectory($src, $zip) Chained PowerShell commands can also be called from a CMD command-lin

如何在特殊的PowerShell链接命令4命令提示符?

通常,PowerShell命令可以用分号链接。 以下打开2个记事本: PS> notepad; notepad 你也可以链接一个更复杂的陈述: PS> Add-Type -AssemblyName System.IO.Compression; ` > $src = "C:aFolder"; $zip="C:my.zip"; ` > [io.compression.zipfile]::CreateFromDirectory($src, $zip) 链式PowerShell命令也可以从CMD命令行调用: C:> powershell notepad; notepad 本文介绍了一种创建.Net 4.0 PowerShell提

Group By Multiple Columns

How can I do GroupBy Multiple Columns in LINQ Something similar to this in SQL: SELECT * FROM <TableName> GROUP BY <Column1>,<Column2> How can I convert this to LINQ: QuantityBreakdown ( MaterialID int, ProductID int, Quantity float ) INSERT INTO @QuantityBreakdown (MaterialID, ProductID, Quantity) SELECT MaterialID, ProductID, SUM(Quantity) FROM @Transactions

按多列分组

我如何在LINQ中做GroupBy多列 在SQL中与此类似的东西: SELECT * FROM <TableName> GROUP BY <Column1>,<Column2> 我如何将其转换为LINQ: QuantityBreakdown ( MaterialID int, ProductID int, Quantity float ) INSERT INTO @QuantityBreakdown (MaterialID, ProductID, Quantity) SELECT MaterialID, ProductID, SUM(Quantity) FROM @Transactions GROUP BY MaterialID, ProductID 使用