Use of volatile causes runtime MissingFieldException on rewritten assembly
-
mardi 29 novembre 2011 22:13
We recently came across an issue when using the volatile keyword and the rewriter.When not using the rewriter, everything worked fine, however when setting Perform Runtime Contract Checking to ReleaseRequires, a MissingFieldException was thrown when it came across the line of code accessing the field:The exception is only thrown if the referenced field is in a separate assembly.private void DoTest() { Test.PerformingTest = true; }
Removing the volatile keyword fixes the issue, but why would the rewriter cause this exception to be thrown?namespace Library { public class Test { public static volatile bool PerformingTest; } }
Toutes les réponses
-
mardi 31 juillet 2012 15:40
I have asked a very similar question on SO. No answers there, either
http://stackoverflow.com/q/11142908/90475
- Modifié GregChernis mardi 31 juillet 2012 15:41
- Modifié GregChernis mardi 31 juillet 2012 15:41
-
mercredi 1 août 2012 15:58PropriétaireSorry about that! Are both assemblies being rewritten? Or just the one referencing the volatile field?
Mike Barnett
-
dimanche 5 août 2012 15:02Propriétaire
I was able to reproduce the problem. The current rewriter doesn't preserve the required modifier on the type of the volatile field reference. At this point we are moving the rewriter to be based on top of a new infrastructure. I have verified that the new code does not display the same problem. We are close enough to releasing the new rewriter that we are not fixing any bugs in the old one. Unfortunately I do not have a firm date at which I can promise the new version, but it should be very soon.
Mike Barnett
- Proposé comme réponse Mike BarnettMicrosoft Employee, Owner dimanche 5 août 2012 15:02
- Modifié Mike BarnettMicrosoft Employee, Owner dimanche 5 août 2012 15:03 fix typo
-
mercredi 24 avril 2013 21:15Propriétaire
I fixed this now. It will appear in the next release.
Cheers, -MaF (Manuel Fahndrich)
- Proposé comme réponse Manuel FahndrichMicrosoft Employee, Owner mercredi 24 avril 2013 21:15

