legacyCasModel = QUOT;真"和动态数据/业务 [英] legacyCasModel="true" and dynamic data/operations

查看:536
本文介绍了legacyCasModel = QUOT;真"和动态数据/业务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是类似于在MVC 3项目奇数异常。

我们在完全信任的ASP.NET 4.0应用程序的运行。我们需要在我们的web.config以下行,我们使用的是不起作用的库,否则之一。 (因为它明确地使用从.net的previous版本现在已经过时CAS模型)。

 <信任legacyCasModel =真/>

鉴于此设置,我们无法使用动态关键字或依赖于它的ASP.NET MVC的某些功能。

作为一个例子,下面code使异常:

 动态D =新的对象();
d.test =贾森;

唯一的例外是:

 动态操作只能在同质AppDomain中进行。

有什么办法可以让动态关键字的工作,如果legacyCasModel设置为true? (如果设置为false,一切工作正常,但需要它的图书馆。)

思路:


  1. 由于我在完全信任运行,我认为在AppDomain中一个程序集是利用降低权限(因此非齐次)。有没有一种方法,我可以简单地告诉它在完全信任模式下运行,使得均匀的AppDomain


  2. 我应该能够重构我的code莫名其妙地加载有问题的装配在另一个AppDomain中?我不熟悉这样的典型的方式,但它似乎复杂。


  3. 有一些其他神奇的配置设置,我可以启用,使工作?



解决方案

我没有用太多DLR的东西,但我只是想快速测试。在一个控制台应用程序您的命令相当于失败...

 动态D =新的对象();
        d.test =贾森;
        Console.WriteLine(d.test);

但这种成功...

 动态D =新ExpandoObject();
        d.test =贾森;
        Console.WriteLine(d.test);

在使用动态对象,你可能需要使用ExpandoObject,而不是普通的旧对象。

在情况下,ExpandoObject不能满足您的需要更强大的东西如 HTTP://clay.$c $ cplex.com /

===编辑===

帮助,如果我完全阅读问题...

添加在<信任legacyCasModel =真实水平=完全/> 的组合会导致两个失败,所提供的错误。

legacyCasModel强制非齐次域名,因为它是做事情的pre-.NET4方式。这意味着,动态对象和您的旧CAS库是不兼容的。

这是我能看到的唯一有效的解决方法是抽象的,年长的CAS库的在一个单独的应用程序域中运行

This is similar to Odd Exception in MVC 3 Project.

We have an ASP.NET 4.0 application running in full trust. We need to have the following line in our web.config, otherwise one of the libraries we are using does not function. (As it explicitly uses the now obsolete CAS model from previous versions of .NET).

<trust legacyCasModel="true" />

Given this setting, we are unable to use the dynamic keyword or certain features of ASP.NET MVC which rely on it.

As an example, the following code causes an exception:

dynamic d = new object();
d.test = "jason";

The exception is:

Dynamic operations can only be performed in homogenous AppDomain.

Is there any way I can make the dynamic keyword work if legacyCasModel is set to true? (If set to false, everything works fine, except the library that requires it.)

Ideas:

  1. Given that I am running in full trust, I assume that one assembly in the AppDomain is utilizing reduced permissions (hence the non-homogeneous). Is there a way I can simply tell it to run in full trust mode, making the AppDomain homogeneous?

  2. Should I be able to refactor my code somehow to load the problematic assembly in another AppDomain? I'm not familiar with typical ways of doing this, but it appears complex.

  3. Is there some other magical configuration setting I can enable to make it work?

解决方案

I haven't used much DLR stuff but I just tried a quick test. In a console application the equivalent of your command fails ...

        dynamic d = new object();
        d.test = "jason";
        Console.WriteLine(d.test);

But this succeeds ...

        dynamic d = new ExpandoObject();
        d.test = "jason";
        Console.WriteLine(d.test);

When using dynamic objects you may need to use ExpandoObject rather than plain old object.

In cases where ExpandoObject doesn't meet your needs something more powerful like http://clay.codeplex.com/

=== EDIT ===

Helps if I read the question fully ...

Adding in <trust legacyCasModel="true" level="Full" /> to the mix causes both to fail with the error provided.

"legacyCasModel" forces a non-homogeneous domain as it is the pre-.net4 way of doing things. This means that dynamic objects and your older CAS library are incompatible.

The only valid workaround that I can see would be to abstract that older CAS library to run in a seperate application domain.

这篇关于legacyCasModel = QUOT;真&QUOT;和动态数据/业务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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