小编Joh*_*ero的帖子

OWIN Startup方法如何获取网站的基本URL?

OWIN启动方法如何获取网站的基本URL?

我正在尝试编写在使用IISExpress进行调试时可以正常工作的代码,使用自托管和IIS进行单元测试.

当自托管时,我可以在IAppBuilder.Properties ["host.Addresses"]中找到此信息但是,当它在IISExpress下运行时(它还没有检查IIS)它不存在.

c# owin

18
推荐指数
1
解决办法
1万
查看次数

为什么 -Verbose 使 Copy-Item 忽略 ErrorActionPreference?

将 -Verbose 添加到 Copy-Item 命令似乎会使该命令忽略 $ErrorActionPreference 的值。这是一个错误还是我不明白的东西?

我认为这个脚本应该在显示“为什么显示这个......”之前停止。

$ErrorActionPreference="Stop"
Get-Variable ErrorActionPreference | out-default
Get-Variable ErrorActionPreference -Scope Script | out-default
Get-Variable ErrorActionPreference -Scope Global | out-default

Copy-Item This.Is.Not.There.dat $Home -Verbose
Write-Host "Why is this displayed? The script should have stopped."

Copy-Item This.Is.Not.There.dat $Home
Write-Host "This is not displayed because the script stops."
Run Code Online (Sandbox Code Playgroud)

这是我得到的输出:


Name                           Value
----                           -----
ErrorActionPreference          Stop



Name                           Value
----                           -----
ErrorActionPreference          Stop



Name                           Value
----                           -----
ErrorActionPreference          Continue


Copy-Item : Cannot find path 'C:\users\John\Documents\This.Is.Not.There.dat' because it does not …
Run Code Online (Sandbox Code Playgroud)

powershell

5
推荐指数
1
解决办法
459
查看次数

为什么重新启动时丢失了密钥容器?

多年以来,我们一直将强名密钥保存在密钥容器中。Visual Studio不直接支持它,但是,如果您只编辑.csproj文件并添加:

<KeyContainerName>MyKeyName</KeyContainerName>
Run Code Online (Sandbox Code Playgroud)

我们通过执行以下操作将密钥安装到密钥存储中:

sn -m Y
sn -i MyKeyFile.snk MyKeyName
Run Code Online (Sandbox Code Playgroud)

然后,我们可以从该计算机上删除MyKeyFile.snk,并且密钥更加安全。

最近,重新启动后这已成为问题。我们怀疑问题是由VS 2015引入的,但可能是Windows 8和/或10引起的。我们将密钥安装到密钥容器中,一切正常。然后,我们重新启动该计算机,并且构建失败并显示以下内容:

CSC : error CS7028: Error signing output with public key from container 'MyKeyName' -- Keyset does not exist (Exception from HRESULT: 0x80090016)
Run Code Online (Sandbox Code Playgroud)

看起来密钥容器在重新启动时丢失了,但是,如果这样做,则:

sn -m Y
sn -i MyKeyFile.snk MyKeyName
Run Code Online (Sandbox Code Playgroud)

它失败并显示:

Failed to install key pair -- Object already exists.
Run Code Online (Sandbox Code Playgroud)

我们必须使用sn -d删除密钥容器,然后将其重新添加,Visual Studio很高兴。

这里发生了什么?当sn可以看到它时,为什么Visual Studio在重新启动后看不到我们的密钥容器?密钥容器实际存储在哪里?

cryptography cryptoapi visual-studio

4
推荐指数
1
解决办法
1107
查看次数

标签 统计

c# ×1

cryptoapi ×1

cryptography ×1

owin ×1

powershell ×1

visual-studio ×1