代码合同:ccrewrite 退出并显示代码 -1?
我是代码合同的新手。我下载了最新版本的代码合约项目(1.4.40314.1)并开始在我的项目中实现它。当我通过 VS2010 中的“代码合同”选项卡启用“运行检查”时,出现此错误
Error 1 The command ""C:\Program Files (x86)\Microsoft\Contracts\Bin\ccrewrite" "@Application1ccrewrite.rsp" 都会以代码 -1 退出。
每次我构建项目时, 请帮忙。
现在这对我来说是一个大问题。 每个使用代码合同的项目都在 VS2010 错误窗口中显示相同的错误,并且在输出窗口中找不到“Application1ccrewrite.rsp”,但它确实存在。
我尝试了一切。我安装了两个版本(Pro、Std),但问题仍然存在。请帮忙!
I'm new to code contracts. I downloaded the latest build of code contract project (1.4.40314.1) and started to implement it in my project. When i enabled 'Runtume Checking' through Code Contracts Tab in VS2010, i got this Error
Error 1 The command ""C:\Program Files (x86)\Microsoft\Contracts\Bin\ccrewrite" "@Application1ccrewrite.rsp"" exited with code -1.
everytime i build the project. Plz help.
Now it's a major problem for me.
Every project using code contracts is showing same error in VS2010 Errors window and 'Application1ccrewrite.rsp' not found in output window, but it is there.
I tried out everything. I installed both versions (Pro, Std) but the problem persist. Plz help !
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我也有这个问题。就我而言,问题是 ccrewrite 无法处理网络文件夹中的文件,但要求项目位于本地硬盘上。
I had this problem as well. In my case the problem was that ccrewrite cannot work with files in a network folder but requires the project to be on your local hard disk.
我遇到了这个问题。导致问题的类库的程序集名称和默认命名空间与目标文件夹中现有的 DLL 具有相同的名称。我一直在重构我的代码,虽然 CS 文件中的命名空间已全部更改为命名空间 2,但属性文件中的默认命名空间仍然是命名空间 1
当我更正此问题时,所有文件都已成功构建......
I had this problem. The Assembly name and Default namespace of the class library that causes the problem had the same name as an existing DLL in the destination folder. I had been refactoring my code and whilst the namespaces in the CS files had all be changed to namespace2 the default namespace in the properties file was still namespace1
When I corrected this the files all built successfully...
有时,当您的解决方案路径太长时,尤其是对于许多项目,您可能会遇到这种情况。
尝试移动到 c:\temp 并构建它,它可能会修复它(当然,如果您在当前所在的文件夹中需要它,这可能不是一个解决方案)。
我在早期的 CC 版本中注意到了这个错误,现在可能已修复。
Sometimes you can get this when your solution path is too long, especially with many projects.
Try moving to c:\temp and building it, it might fix it (although of course, this might not be a solution if you need it in the folder it currently is).
This bug I noticed in earlier CC versions and may now be fixed.
不知道你是否也遇到了和我一样的问题,但我也看到了这个错误。就我而言,我有一个带有 switch 语句的方法,并且根据所采用的分支,应用了不同的要求:
当我尝试构建时,这给了我您在错误列表中指出的错误。在输出窗口中,我得到了这个:
我将每个分支推入其自己的方法中,使 Contract.Requires 每个方法中的第一行代码,并且我不再遇到编译问题。看来 Contract.Requires 必须是方法中的第一行代码 - 这是有道理的,因为它们旨在用于定义前置条件。
希望这有帮助。
I don't know if you had the same problem as me, but I also saw this error. In my case, I had a method with a switch statement, and depending on the branch taken, different requirements applied:
This was giving me the error you noted in the Errors List when I tried to build. In the output window, I was getting this:
I pushed each branch into a method of its own, making Contract.Requires the first lines of code in each method, and I no longer had a compilation problem. It appears that Contract.Requires must be the first lines of code in a method - which makes sense, since they are intended to be used to define pre-conditions.
Hope this helps.
解决方案是将前置条件和后置条件放在第一行。 ccrewrite 不接受前置条件和后置条件位于命令行下方。
The solution is to put the pre and pos conditions in the first lines. The ccrewrite does not accept that pre and post conditions are below command lines.