InvalidOperationException:动态操作只能在同源AppDomain中执行 [英] InvalidOperationException: Dynamic operations can only be performed in homogenous AppDomain

查看:637
本文介绍了InvalidOperationException:动态操作只能在同源AppDomain中执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我在使用moles和DLR同时引发此异常时遇到问题:InvalidOperationException:动态操作只能在同类AppDomain中执行

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

我猜它正在抛出,因为Moles测试主机不会创建一个同质的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); 
  } 
 } 
} 

推荐答案

我似乎无法找到更多相关信息。我在这里更深入地发表了博客文章:

http://cameronfletcher.com/post/InvalidOperationException-Dynamic-operations-can-only-be-performed-in-homogenous-AppDomain.aspx


这篇关于InvalidOperationException:动态操作只能在同源AppDomain中执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆