Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 948603
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T23:16:10+00:00 2026-05-15T23:16:10+00:00

I’ve recently migrated a lot of manual precondition testing and exception throwing with code

  • 0

I’ve recently migrated a lot of manual precondition testing and exception throwing with code contracts. Instead of upgrading to .NET 4, I’ve been using the Microsoft.Contracts.dll assembly so I could stick to .NET 3.5 a bit longer (this is a library that is used both by .NET 3.5 and .NET 4 assemblies). I’ve set up the contracts rewriter in Visual Studio 2010 and the contracts work just fine.

However, since I’ve done that switch, I’ve noticed that the debugger acts funny in methods with contracts, especially in classes with a ContractInvariantMethod. The execution cursor doesn’t seem to always match the highlighted line, some breakpoints fail to be hit and I’ve had a method in which the debugger couldn’t tell the local variable names and would show stuff like CS$1$0000. This is in debug builds.

Are there known issues about using the code contracts in Microsoft.Contracts.dll in .NET 3.5 through VS10?
Do similar issues arise with the code contracts in .NET 4?

[Edit] This question lead me to create a bug on Microsoft Connect: https://connect.microsoft.com/VisualStudio/feedback/details/573983/code-contract-rewriting-messes-up-local-variable-names-in-iterator-methods-while-debugging

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T23:16:11+00:00Added an answer on May 15, 2026 at 11:16 pm

    I hope you know what contract rewriting means—extra code generated on the fly which doesn’t have any source code for compiler to latch on. With CLR having so many different elements, there’s quite a number of things that debugger either won’t do at all or will get confused and only things which are full blown language features with wide impact get the budget for complete debugger support. Like lambda expressions for example.

    Which is not to say that filing a bug is not for a good cause, just that you shouldn’t expect anything to turn better when you are using an aspect which is not even fully developed yet. Being early adopter always has that kind of cost, but also the bragging rights 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.