简体   繁体   English

假货和 .net Framework 4.6.1 和系统

[英]Fakes and .net Framework 4.6.1 and System

When setting an OOB default Visual Studio 2013 Update 5 Project, with no tests setup, using the Target Framework of 4.6.1, adding a Fakes assembly to System and setting the following ShimGenerations:设置 OOB 默认 Visual Studio 2013 Update 5 项目时,未设置测试,使用 4.6.1 的目标框架,向系统添加 Fakes 程序集并设置以下 ShimGenerations:

mscorlib.fakes: mscorlib.fakes:

<ShimGeneration>
    <Clear/>
    <Add FullName="System.Collections.ReadOnlyCollectionBase"/>
    <Add FullName="System.ApplicationException"/>
    <Add FullName="System.IO.Path"/>
    <Add FullName="System.Security.SecureString"/>
    <Add FullName="Microsoft.Win32.Registry"/>
    <Add FullName="Microsoft.Win32.RegistryKey"/>
    <Add FullName="System.Activator"/>
    <Add FullName="System.Convert"/>
    <Add FullName="System.Version"/>
    <Add FullName="System.StringComparer"/>
    <Add FullName="System.Threading.Thread"/>
</ShimGeneration>

System.fakes: System.fakes:

<ShimGeneration>
    <Clear/>
    <Add FullName="System.Text.RegularExpressions.Regex"/>
    <Add FullName="System.Diagnostics.FileVersionInfo"/>
    <Add FullName="System.Diagnostics.Process"/>
    <Add FullName="System.Net.CookieContainer"/>
    <Add FullName="System.Net.FtpWebRequest"/>
    <Add FullName="System.Net.FtpWebResponse"/>
    <Add FullName="System.Net.IPAddress"/>
    <Add FullName="System.Net.Dns"/>
    <Add FullName="System.Net.Mail.SmtpClient"/>
    <Add FullName="System.Net.Mail.MailMessage"/>
    <Add FullName="System.Net.NetworkInformation.Ping"/>
    <Add FullName="System.Net.NetworkInformation.PingReply"/>
    <Add FullName="System.Net.NetworkInformation.PingException"/>
    <Add FullName="System.Net.HttpWebRequest"/>
    <Add FullName="System.Net.HttpWebResponse"/>
    <Add FullName="System.Net.WebHeaderCollection"/>
    <Add FullName="System.Net.ServicePoint"/>
    <Add FullName="System.Net.NetworkInformation.NetworkInterface"/>
    <Add FullName="System.Net.Sockets.TcpClient"/>
    <Add FullName="System.Net.Sockets.UdpClient"/>
    <Add FullName="System.Net.Sockets.Socket"/>
    <Add FullName="System.Net.WebRequestMethods"/>
    <Add FullName="System.Net.WebRequest"/>
    <Add FullName="System.Uri"/>
</ShimGeneration>

The following error occurs:出现以下错误:

'System.Net.Sockets.SocketClientAccessPolicyProtocol' is obsolete: 'This API supports the .NET Framework infrastructure and is not intended to be used directly from your code.' “System.Net.Sockets.SocketClientAccessPolicyProtocol”已过时:“此 API 支持 .NET Framework 基础结构,不应直接从您的代码中使用。”
[some path\\TestFakes\\UnitTestProject1\\obj\\Debug\\Fakes\\s\\f.csproj] some path\\TestFakes\\UnitTestProject1\\f.cs [一些路径\\TestFakes\\UnitTestProject1\\obj\\Debug\\Fakes\\s\\f.csproj] 一些路径\\TestFakes\\UnitTestProject1\\f.cs

GENERATEFAKES : error : project compilation failed with exit code 1 GENERATEFAKES:错误:项目编译失败,退出代码为 1

This appears to only to occur with this configuration.这似乎只发生在此配置中。

I am not sure how to work around this since I need to intercept most of the .NET framework calls.我不确定如何解决这个问题,因为我需要拦截大部分 .NET 框架调用。

After spending a couple of days on this problem, I found the following.在这个问题上花了几天时间后,我发现了以下内容。 This is a problem with the following class "System.Net.Sockets.Socket".这是以下类“System.Net.Sockets.Socket”的问题。 I found that removing this shim generation, then removing all of the .fakes assemblies, then removing one of the .fakes files in the/Fakes folder and recreating it with the "Add Fakes Assembly" dialogue, recreates all of the .fakes assemblies based on the .fakes files in the /Fakes folder and allows the code to build.我发现删除这个 shim 生成,然后删除所有 .fakes 程序集,然后删除 /Fakes 文件夹中的一个 .fakes 文件并使用“添加假冒程序集”对话框重新创建它,重新创建所有基于 .fakes 程序集的程序集在 /Fakes 文件夹中的 .fakes 文件上,并允许构建代码。

Since I did not need to fake "System.Net.Sockets.Socket", this was an acceptable solution to successfully building and rerunning my unit tests.由于我不需要伪造“System.Net.Sockets.Socket”,因此这是成功构建和重新运行单元测试的可接受解决方案。 This definitely appears to be a problem specifically with this class and the Fakes framework.这绝对是这个类和 Fakes 框架的一个问题。

I find that the Fakes framework is a good one but needs better support.我发现 Fakes 框架是一个很好的框架,但需要更好的支持。 Things like this are too difficult to troubleshoot and need improvement.像这样的事情很难排除故障,需要改进。 To me the above is not an acceptable solution to the overall.对我来说,以上不是整体的可接受的解决方案。 I find that if MS would provide better feedback and more verbosity on such a problem as above, a solution to it would be simpler.我发现,如果 MS 能够对上述问题提供更好的反馈和更详细的信息,那么解决方案会更简单。 One should not have to spend days looking at logs, researching on the web and testing when a simple message such as "This class is unsupported for Shim Generation" would suffice.当一条简单的消息(例如“Shim Generation 不支持该类”)就足够时,人们不应该花费数天时间查看日志、在网络上进行研究和测试。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 .NET Framework 4.6.1 System.Windows.Forms错误 - .NET Framework 4.6.1 error with System.Windows.Forms 假货不支持框架 .net 5 - Fakes does not support framework .net 5 如何使用 C# 代码检测系统上是否安装了“.Net Framework 4.6.1 Hotfix”? - How to detect whether “.Net Framework 4.6.1 Hotfix” is installed on System or not using C# Code? .NET FRAMEWORK 4.6.1在此操作系统上不受支持-通过Visual Studio Community 2017供软件开发人员使用 - .NET FRAMEWORK 4.6.1 is not supported on this operating system - for Software Developer through Visual Studio Community 2017 无法加载与“ System.Diagnostics.DiagnosticsSource”文件一起使用4.6.1的Net Framework App中的错误 - Error in Net Framework App Using 4.6.1 with “System.Diagnostics.DiagnosticsSource” File Not Load 在带有.NET Core(.NET Standard 1.4和.NET Framework 4.6.1)的System.Net.Http中使用await / async时出现错误? - Bug when using await/async for System.Net.Http with .NET Core (.NET Standard 1.4 and .NET Framework 4.6.1)? 如何在.NET Framework 4.6.1中使用IActionResult? - How to use IActionResult in .NET Framework 4.6.1? 将 .NET Framework 4.6.1 更新到 4.8 后出错 - Error after updating .NET Framework 4.6.1 to 4.8 在 Xamarin 项目中面向 .NET Framework 4.6.1 - Targeting .NET Framework 4.6.1 in Xamarin project 将.NET Framework升级到4.6.1并获取套接字异常 - Upgraded .NET Framework to 4.6.1 and getting socket exceptions
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM