如果我在powershell脚本中执行以下操作:
$range = 1..100
ForEach ($_ in $range) {
if ($_ % 7 -ne 0 ) { continue; }
Write-Host "$($_) is a multiple of 7"
}
Run Code Online (Sandbox Code Playgroud)
我得到了预期的输出:
7 is a multiple of 7
14 is a multiple of 7
21 is a multiple of 7
28 is a multiple of 7
35 is a multiple of 7
42 is a multiple of 7
49 is a multiple of 7
56 is a multiple of 7
63 is a multiple …Run Code Online (Sandbox Code Playgroud) 我试图通过向控制台发送消息来"printf()调试"我的Visual Studio项目文件,如下所示:
<Target Name="BeforeBuild">
<Message Text="+++++++++++++++++++++++ Justin Dearing ++++++++++++++++++++++++++++++++++++" />
</Target>
Run Code Online (Sandbox Code Playgroud)
这可以从命令行工作:
BeforeBuild:
+++++++++++++++++++++++ Justin Dearing ++++++++++++++++++++++++++++++++++++
Run Code Online (Sandbox Code Playgroud)
但是,消息不会显示在Visual Studio 2010构建输出中.是否有我可以使用的替代msbuild任务,或者Visual Studio中的设置我可以启用这些消息吗?
请考虑以下PowerShell代码段:
$csharpString = @"
using System;
public sealed class MyClass
{
public MyClass() { }
public override string ToString() {
return "This is my class. There are many others " +
"like it, but this one is mine.";
}
}
"@
Add-Type -TypeDefinition $csharpString;
$myObject = New-Object MyClass
Write-Host $myObject.ToString();
Run Code Online (Sandbox Code Playgroud)
如果我在同一个AppDomain中多次运行它(例如在powershell.exe或powershell_ise.exe中运行两次脚本),我会收到以下错误:
Add-Type : Cannot add type. The type name 'MyClass' already exists.
At line:13 char:1
+ Add-Type -TypeDefinition $csharpString;
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (MyClass:String) [Add-Type],
Exception
+ FullyQualifiedErrorId …Run Code Online (Sandbox Code Playgroud) 情况就是这样.我有一些看起来像这样的JavaScript:
function onSubmit() {
doSomeStuff();
someSpan.style.display="block";
otherSpan.style.display="none";
return doLongRunningOperation;
}
Run Code Online (Sandbox Code Playgroud)
当我将其作为表单提交操作并从非IE浏览器运行时,它会快速交换两个跨度可见性并运行长时间的javascript操作.如果我在IE中执行此操作,则直到onSubmit()完全返回后才会执行交换.
我可以通过粘贴一个警告框来强制重绘:
function onSubmit() {
doSomeStuff();
someSpan.style.display="block";
otherSpan.style.display="none";
alert("refresh forced");
return doLongRunningOperation;
}
Run Code Online (Sandbox Code Playgroud)
此外,明显的jquery重构不会影响IE行为:
function onSubmit() {
doSomeStuff();
$("#someSpan").show();
$("#otherSpan").hide();
return doLongRunningOperation;
}
Run Code Online (Sandbox Code Playgroud)
IE8和IE6上存在此行为.反正是否强制在这些浏览器中重绘DOM?
最初的问题是"如何将WinMerge配置为TFS的比较和合并工具".但是,我正在改变它,因为TehOne回答了这个问题的更一般形式.
虽然我会在Stackoverflow上已经提出过这个问题.我在其他地方找到了答案,但我在这里问/回答.它现在是一个社区维基.
我通过Mount-DiskImage命令安装了ISO I.但是,我不知道如何获取已安装磁盘映像的驱动器号.我试试$mountResult = Mount-DiskImage D:\ISOs\clonezilla-live-1.2.12-10-i486.iso -PassThru.返回的信息都不是驱动器号,如下所示:
PS C:\Windows\system32> $mountResult | fl *
Attached : False
BlockSize : 0
DevicePath :
FileSize : 110100480
ImagePath : D:\ISOs\clonezilla-live-1.2.12-10-i486.iso
LogicalSectorSize : 2048
Number :
Size : 110100480
StorageType : 1
PSComputerName :
CimClass : ROOT/Microsoft/Windows/Storage:MSFT_DiskImage
CimInstanceProperties : {Attached, BlockSize, DevicePath, FileSize...}
CimSystemProperties : Microsoft.Management.Infrastructure.CimSystemProperties
PS C:\Windows\system32> $mountResult | select -ExpandProperty CimSystemProperties | fl *
Namespace : ROOT/Microsoft/Windows/Storage
ServerName : ECHO-BASE
ClassName : MSFT_DiskImage
Path :
Run Code Online (Sandbox Code Playgroud)
之后调用Get-DiskImage D:\ISOs\clonezilla-live-1.2.12-10-i486.iso也不返回驱动器号. …
我有一个用C#编写的Web服务,它位于SharePoint站点上.我使用以下代码修改了web.config:
<configuration>
<system.web>
<httpRuntime executionTimeout="360" />
Run Code Online (Sandbox Code Playgroud)
...
对于IIS Inetpub文件,SP ISAPI web.config文件和SP布局web.config.我还使用相同的代码修改了machine.config文件,并试图阻止我在IIS中看到的任何超时.
当我从Windows C#应用程序调用此Web服务时,我可以进入Web方法并开始调试变量,但在很短的时间后(约1分钟,可能更少),变量值不再存在,因为它返回:
System.Net.WebException"请求已中止:操作已超时."
我试图弄清楚需要设置正确的超时值以及如何设置.我在完成所有更改后重新启动IIS,但没有任何更改以提供不同的结果.
谢谢
PowerGUI的一个功能是能够重置Powershell Runspace,如本文和本文所示.是否可以在PowerShell ISE中执行此操作?
我有一个maven项目,它通过我希望作为控制台应用程序运行的maven程序集插件生成一个jar .但是,未在MANIFEST.MF中设置MainClass属性.这是我的插件配置:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2.1</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>net.justaprogrammer.poi.cleanser.Cleanser</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
但是,这不会被添加到生成的jar中的MANIFEST.MF中mvn package.生成的清单如下:
Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Created-By: Apache Maven
Built-By: zippy
Build-Jdk: 1.6.0_25
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?
在SQL Server 2005中,有内置角色:
拥有db_datareader
db_datawriter权限
等等
是否有任何角色可以让用户执行存储过程?
我不想使用db_owner,因为这将允许删除和更新,这是我不需要的.我需要的唯一权限是:
选择
执行
powershell ×4
.net ×1
add-type ×1
c# ×1
dom ×1
foreach ×1
javascript ×1
maven-2 ×1
merge ×1
msbuild ×1
permissions ×1
roles ×1
sql ×1
sql-server ×1
tfs ×1
timeout ×1
web-services ×1
winmerge ×1