VerificationException thrown when calling typeof().Equals() call from a .NET 3.5 referenced assembly in a non full trust ASP.NET 4.0 application - by turtlespin

Status : 

  Won't Fix<br /><br />
		Due to several factors the product team decided to focus its efforts on other items.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.

Sign in
to vote
ID 587594 Comments
Status Closed Workarounds
Type Bug Repros 0
Opened 8/19/2010 2:56:54 PM
Access Restriction Public


If a ASP.NET 4.0 web application which is not running in FullTrust references a .NET 3.5 targetted assembly which has a typeof().Equals() call such as

if (typeof(Foo).Equals(typeof(Bar))) { ...

then a VerificationException will be incorrectly thrown when trying to make that call.

No exception was previously thrown when running the ASP.NET application in medium trust under 2.0, nor is the exception thrown if the .NET 3.5 assembly is upgraded to target the 4.0 framework, nor is the exception thrown if we upgrade the application to running in FullTrust.

Presumably this is being incorrectly thrown because of some error in checking if this code is valid for running under lower trust profiles, and there is some difference in the way that code is emitted between 2.x and 4.x targetted assemblies.
Sign in to post a comment.
Posted by Microsoft on 12/29/2010 at 1:59 PM
Thanks for reporting this issue you've encountered with Visual Studio!

We've reproduced this issue and determined that the root cause is a bug in the C# Compiler that causes it to emit invalid IL when the literal expression "typeof(T).Equals(typeof(T))" is encountered, where T is a valid type expression. However, the issue does not occur if either typeof expression is some other expression that evaluates to a type.

Given that this codegen issue only seems to occur in cases that are trivially reducible to true or false in source by the developer, fixing this falls lower in priority than fixing other reported compiler bugs. We won't be able to fix this bug in the next version of Visual Studio.

Alex Turner
Program Manager
Visual Basic and C# Compiler
Posted by Microsoft on 8/23/2010 at 11:48 PM
Thanks for your feedback.

We are rerouting this issue to the appropriate group within the Visual Studio Product Team for triage and resolution. These specialized experts will follow-up with your issue.
Posted by turtlespin on 8/22/2010 at 10:53 PM
I have added a repro solution - build and run will trigger the VerificationException
Posted by Microsoft on 8/19/2010 at 10:35 PM
Thanks for reporting this issue. In order to fix the issue, we must first reproduce the issue in our labs. We are unable to reproduce the issue with the steps you provided.

Please give us a demo project to demonstrate this issue so that we can conduct further research.

It would be greatly appreciated if you could provide us with that information as quickly as possible. If we do not hear back from you within 7 days, we will close this issue.

Thanks again for your efforts and we look forward to hearing from you.

Microsoft Visual Studio Connect Support Team
Posted by Microsoft on 8/19/2010 at 5:13 PM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(