chevron-thin-right chevron-thin-left brand cancel-circle search youtube-icon google-plus-icon linkedin-icon facebook-icon twitter-icon toolbox download check linkedin phone twitter-old google-plus facebook profile-male chat calendar profile-male
0 votes
We are using Isolator 6.0.4.0, and are also early adopting ASP.NET MVC3 with razor views.

If we have Isolator installed, trying to consstruct a controller in the test project throw a System.Security.VerificationException: Operation could destabilize the runtime.

If we uninstall Isolator, everything works.

Do we need to wait for an update to Isolator before we can run any unit tests?

Any help would be appreciated.
asked by ChadYost (680 points)

16 Answers

0 votes
Hi Chad,

Thanks for reporting about this issue.

Can you please post a code sample for the problem?
As a workaround until we'll fix the problem if you are not using the Isolator in this test you can disable it from the Typemock menu in Visual Studio.

Our policy for bug fixing is to send the users that found the issue a patch as soon as possible so they will not have to wait for the next release.
Also a bug is fixed only when the user who reported it says it's fixed and not when we think it's fixed :) so we want the user to use the patch before we are releasing a new version.
answered by ohad (35.5k points)
0 votes
I don't really even have to send a sample.

Download the beta for MVC3 from http://www.microsoft.com/downloads/en/d ... bf300b2c51.

Create a brand new MVC product (File->New->Project->ASP.NET MVC 3 Web Application).

From the dialog, Select "Internet Application", and check the "Create a unit test project" checkbox.

Try and run the HomeControllerTest.Index() test and it will fail with the exception.

We do need to use typemock, as we need to mock access to our Model class library.
answered by ChadYost (680 points)
0 votes
Hi Chad,

Thanks, we'll try that out and let you know the results.
answered by ohad (35.5k points)
0 votes
Any update to this issue. Though we just typemock exclusively today, some of our management is starting to consider going elsewhere due to not being able to test our new code.

chad
answered by ChadYost (680 points)
0 votes
Hi Chad,

We reproduced the error you reported about and it seems that the it happens just because Isolator is injecting code. We contact MS folks to help us out with it.
I'll update you once we'll have an answer.
answered by ohad (35.5k points)
0 votes
Hi all.
Do you have any updates to this issue?
We faced with this issue too.
Thanks.
answered by Stilay (180 points)
0 votes
Hi,

We are working to solve this problem now.
Hopefully there will be a patch ready this week.
We'll announce about it here once it will be ready.
answered by ohad (35.5k points)
0 votes
Hi All,

We created a patch that should solve the problem for MVC3
You can download the patch from this link:
https://www.typemock.com/patches/Typemoc ... .6.355.msi

Please let us know if it solves the problem.
answered by ohad (35.5k points)
0 votes
Hi Ohad,

After the patch all my issues were solved.
Thanks!
answered by Stilay (180 points)
0 votes
I am having this problem too.

I just installed version 6.0.7.0 about an hour again and I'm still getting this error.

So here's the rundown, we're using RIA System.ServiceModel.DomainServices dll.

The test I have isolating the issue works fine with the TypeMock dlls not included in the solution, but once I include them I get this error:
Error 1 Test 'GameFly.Enterprise.Retail.UnitTest.Validation.NastyGrossReflectionStuffTestFixture.TryValidate_ShouldNotThrowVerificationException' failed:
Test method GameFly.Enterprise.Retail.UnitTest.Validation.NastyGrossReflectionStuffTestFixture.TryValidate_ShouldNotThrowVerificationException threw exception:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Security.VerificationException: Operation could destabilize the runtime.
at System.ServiceModel.DomainServices.Server.MetaType.<>c__DisplayClass1..ctor()
at System.ServiceModel.DomainServices.Server.MetaType.GetMetaType(Type type)
at System.ServiceModel.DomainServices.Server.ValidationUtilities.TryValidateObjectRecursive(Object instance, String memberPath, ValidationContext validationContext, List`1 validationResults)
at System.ServiceModel.DomainServices.Server.ValidationUtilities.TryValidateObject(Object instance, ValidationContext validationContext, List`1 validationResults)
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle._InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeType typeOwner)
at System.RuntimeMethodHandle.InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeType typeOwner)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
at GameFly.Enterprise.Retail.UnitTest.Validation.NastyGrossReflectionStuffTestFixture.TryValidate_ShouldNotThrowVerificationException()


Here's my code, I know I have some nasty reflection stuff going on, I'm sorry but I need this code and i don't want to have to write code that does the same thing as this. Besides BOO to microsoft for hiding these gems from me. So yes, this is nasty not very maintainable code but I'm doing it and TypeMock is not playing nice with it.

[TestClass]
   public class NastyGrossReflectionStuffTestFixture {

      /// <summary>
      /// Please don't throw this error
      /// </summary>
      [TestMethod]
      public void TryValidate_ShouldNotThrowVerificationException() {

         var fBar = new FooBar
                  {
                     Name = "Captain FooBar!!!"
                  };


         var context = new ValidationContext(fBar, null, null);

         var assembly = typeof (DomainService).Assembly;
         var type = assembly.GetType("System.ServiceModel.DomainServices.Server.ValidationUtilities");
         var method = type.GetMethod("TryValidateObject", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public);

         var result = (bool) method.Invoke(method.DeclaringType.Module, new object[] {fBar, context, new List<ValidationResult>()});

         Assert.IsTrue(result);


      }

      public class FooBar {


         [Required(ErrorMessage = "The parent  name is required")]
         public string Name {
            get;
            set;
         }

      }
   }
answered by someguynameddylan (140 points)
...