为什么ccrewrite.exe没有做从命令行什么? [英] Why is ccrewrite.exe not doing anything from the command line?
问题描述
我有code合同从Visual Studio 2010的内部工作正常,但我不能让 ccrewrite.exe
在命令行做任何有用。下面是一个示例应用程序:
I've got Code Contracts working fine from inside Visual Studio 2010, but I can't get ccrewrite.exe
to do anything useful from the command line. Here's a sample app:
using System.Diagnostics.Contracts;
public class Dummy
{
public static void Main(string[] args)
{
Contract.Requires(args.Length > 0);
}
}
我然后编译code和在其上运行ccrewrite.exe:
I then compile the code and run ccrewrite.exe on it:
> csc /debug+ /D:CONTRACTS_FULL Dummy.cs
> ccrewrite /o:RewrittenDummy.exe Dummy.exe
elapsed time: 61ms
有没有 RewrittenDummy.exe
文件之后。
我试过的选择加载,但什么也没有做任何的区别。有几件事情我已经注意到了:
I've tried loads of options, but nothing's making any difference. A few things I've noticed:
- 这肯定加载Dummy.exe,因为如果我指定一个不存在的文件,它死
- Dummy.exe肯定包含对合约方 - 如果我不带参数运行它,它恰当地失败(但错误消息尚未填写为我期望它已被重写)
- 使用后置条件和不变量没有什么区别
我试着转动警告和冗长了,这不利于在所有 我究竟做错了什么?
I've tried turning warnings and verbosity up, and that doesn't help at all What am I doing wrong?
(同时要求为<一个href="http://social.msdn.microsoft.com/Forums/en-US/$c$ccontracts/thread/0cf6ce81-4778-4ec5-adfe-c12c9da23c7e">question在code合同论坛。我会在这里添加任何相关的答案喽。)
(Also asked as a question in the Code Contracts forum. I'll add any relevant answers here myself.)
推荐答案
好了,这一直是<一href="http://social.msdn.microsoft.com/Forums/en-US/$c$ccontracts/thread/0cf6ce81-4778-4ec5-adfe-c12c9da23c7e">answered在MSDN论坛。这一次,它是不是真的我是完全愚蠢的 - 它的东西,真的可以用一个警告做
Okay, this has been answered in the MSDN forum. For once, it wasn't really me being entirely stupid - it's something that could really do with a warning.
看了论坛帖子的全部细节,但基本的问题是, ccrewrite
找不到合同类:这是看在.NET 3.5 CLR版本的mscorlib
而不是.NET 4.0之一。
Read the forum post for full details, but the basic problem is that ccrewrite
couldn't find the contract classes: it was looking in the .NET 3.5 CLR version of mscorlib
instead of the .NET 4.0 one.
这可以修复明确列出的路径到相关的组件:
This can be fixed by explicitly listing the path to the relevant assembly:
> ccrewrite /o:rewrittendummy.exe dummy.exe
/libpaths:%SystemRoot%\Microsoft.Net\Framework\v4.0.20506
这篇关于为什么ccrewrite.exe没有做从命令行什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!