locked
InvalidOperationException: Dynamic operations can only be performed in homogenous AppDomain

    Question

  • I have an issue when using moles and the DLR at the same time that causes this exception to be thrown: InvalidOperationException: Dynamic operations can only be performed in homogenous AppDomain

    I guess it's throwing because the Moles test host doesn't create a homogenous AppDomain. The code that will cause the exception can be found below.

    using System.IO; 
    using System.IO.Moles; 
    using Microsoft.VisualStudio.TestTools.UnitTesting; 
    
    [TestClass] 
    public classFileWrapperTest 
    { 
     [TestMethod, HostType("Moles")] 
     publicvoid TestMethod1() 
     { 
      // arrange 
      var fileWrapper = new FileWrapper(); 
      MFile.ExistsString = path => false; 
    
      // act
      dynamic exists = fileWrapper.DoesExist(@"C:\temp\test.txt"); 
    
      // assert
      Assert.IsFalse(exists); 
     } 
    
     public classFileWrapper 
     { 
      public bool DoesExist(string path) 
      { 
       return File.Exists(path); 
      } 
     } 
    } 
    
    

    My current work around is not to use the DLR inside a Moles test host. Is this a know issue or is there a way to make the Appdomain homogenous?

    Saturday, November 27, 2010 11:10 AM

All replies