摘要
我在2017年和2019年打开了一个.NET461解决方案,并试图编译它。构建正在抱怨在相应的测试项目中找不到ShimWindowsIdentity。在Visual 2015中,构建,特别是ShimWindowsIdentity没有问题。
目标
我需要使用WindowsIdentity的构造函数来对函数进行单元测试。我知道包装WindowsIdentity是有可能的,但这需要我现在避免的代码更改(重构)。
到目前为止尝试过
为了使WindowsIdentity的shims在VS 2017/2019中工作,我尝试并检查了以下内容:
mscorlib.fakes所需的存根和短消息TargetFrameworkVersion v4.6.1mscorlib.fakes
<Fakes xmlns="http://schemas.microsoft.com/fakes/2011/">
<Assembly Name="mscorlib" Version="4.0.0.0"/>
<StubGeneration>
<Clear />
<Add FullName="System.IO.Stream!"/>
</StubGeneration>
<ShimGeneration>
<Clear/>
<Add FullName="System.Security.Principal"/>
<Add FullName="System.DateTime!"/>
<Add FullName="System.IO.Stream!"/>
</ShimGeneration>
</Fakes>期望
生成用于WindowsIdentiy的shims。
实际
我在mscorlib.4.0.0.0.Fakes.messages中看到了以下警告:Cannot generate shim for System.Security.Principal.WindowsIdentity: type is not supported because it is not available or changed between versions.
发布于 2019-11-22 10:49:37
玩得很开心,试着假装HttpRequest.LogonUserIdentity
对我来说,除了我的web应用程序是内置在(4.6.1)中之外,针对其他版本没有任何意义,所以我放弃了,用假包装伪造了HttpRequestBase类,并夸大了httpRequest.LogonUserIdenity,返回了我所需要的东西。
https://stackoverflow.com/questions/55627066
复制相似问题