尝试添加新单元测试时出现Invalidmetadataexception [英] Invalidmetadataexception on attempting to add new unit test

查看:71
本文介绍了尝试添加新单元测试时出现Invalidmetadataexception的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我打算开始尝试针对我们多年未经过自动化测试的项目进行一些单元测试。 我在解决方案中添加了一个新的Test项目,然后尝试使用新的Create Unit Test对话框。 (右击
test project | Add | Unit Test ...) 这显示了解决方案中的项目列表,其中两个我可以扩展条目并查看类等。 对于我实际上对编写测试感兴趣的那个,但是,尝试扩展,选择,
或以其他方式与项目交互会抛出以下异常对话框:

I was going to start trying to do some unit testing against a project we've been working on for several years without automated testing.  I added a new Test project to the solution, and then attempted to use the new Create Unit Test dialog. (Right click test project | Add | Unit Test...)  This shows the list of projects in the solution, and for two of them I can expand the entry and see classes etc.  For the one I'm actually interested in writing tests against, however, attempting to expand, select, or otherwise interact with the project throws the following exception dialog:

InvalidMetadataException

InvalidMetadataException

读取模块'System.Core'时遇到以下错误:无法解析类型引用:[System,Version = 2.0.0.0,Culture = neutral,publicKeyToken = b77a5c561934e089] System.Collections .Generic.ISet`1。

The following error was encountered while reading module 'System.Core': Could not resolve type reference: [System, Version=2.0.0.0, Culture=neutral, publicKeyToken=b77a5c561934e089]System.Collections.Generic.ISet`1.

失败的项目是.NET 4项目,但包含对另一个项目.NET II的引用。 每个项目都为项目引用了适当的System版本,并且在失败的项目中出现System.Core用法是
,通常是Linq表达式。 有关解决此问题或获取更多有用信息以帮助解决向导中的问题的任何建议吗?

The project which is failing is a .NET 4 project, but includes a reference to another project which is .NET 2.  Each project references the appropriate version of System for the project, and in the failing project appears the System.Core usages are typically Linq expressions.  Any suggestions on troubleshooting this or otherwise getting more useful information to help fix the problem in the wizard?

推荐答案

您好,

根据您的描述,您可以先向解决方案添加测试项目,然后在项目中添加对"System.Core"的引用。 之后,在新的创建单元测试对话框,选择之前创建的项目作为
单元测试的容器。

Based on your descriptions, you may first add a test project to the solution, then add a reference to 'System.Core' in the project. After these,  in the new Create Unit Test dialog, choose the project created before as the container for the unit test.

谢谢。


这篇关于尝试添加新单元测试时出现Invalidmetadataexception的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆