【问题标题】:are not permitted to be deserialized at this security level不允许在此安全级别反序列化
【发布时间】:2017-07-21 18:31:03
【问题描述】:

我有一个应用程序可以在其他任何地方工作,除了 2 个服务器之间。网络和应用程序。 Web 使用 .NET 远程处理应用服务器。

我们的 typeFilterLevel= Full 和远程处理适用于 Global.asax 但不适用于 .aspx 页面。

以下是错误。

Raw url: /welcome.aspx
System.Security.SecurityException: Type System.Runtime.Remoting.ObjRef and the types derived from it (such as System.Runtime.Remoting.ObjRef) are not permitted to be deserialized at this security level.

Server stack trace: 
   at System.Runtime.Serialization.FormatterServices.CheckTypeSecurity(Type t, TypeFilterLevel securityLevel)
   at System.Runtime.Serialization.Formatters.Binary.ObjectReader.CheckSecurity(ParseRecord pr)
   at System.Runtime.Serialization.Formatters.Binary.ObjectReader.ParseObject(ParseRecord pr)
   at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.Run()
   at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
   at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
   at System.Runtime.Remoting.Channels.CoreChannel.DeserializeBinaryRequestMessage(String objectUri, Stream inputStream, Boolean bStrictBinding, TypeFilterLevel securityLevel)
   at System.Runtime.Remoting.Channels.BinaryServerFormatterSink.ProcessMessage(IServerChannelSinkStack sinkStack, IMessage requestMsg, ITransportHeaders requestHeaders, Stream requestStream, IMessage& responseMsg, ITransportHeaders& responseHeaders, Stream& responseStream)

Exception rethrown at [0]: 
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
   at System.Runtime.Remoting.Activation.IActivator.Activate(IConstructionCallMessage msg)
   at System.Runtime.Remoting.Messaging.ClientContextTerminatorSink.SyncProcessMessage(IMessage reqMsg)
   at System.Runtime.Remoting.Activation.ActivationServices.Activate(RemotingProxy remProxy, IConstructionCallMessage ctorMsg)
   at System.Runtime.Remoting.Proxies.RemotingProxy.InternalActivate(IConstructionCallMessage ctorMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
   at OnSIS.Common.Utilities..ctor()
   at OnSIS.Web.Welcome..ctor()
   at ASP.welcome_aspx..ctor()
   at __ASP.FastObjectFactory_app_web_welcome_aspx_cdcab7d2_gkkoykn5.Create_ASP_welcome_aspx()
   at System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(VirtualPath virtualPath, Type requiredBaseType, HttpContext context, Boolean allowCrossApp)
   at System.Web.UI.PageHandlerFactory.GetHandlerHelper(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath)
   at System.Web.HttpApplication.MapHttpHandler(HttpContext context, String requestType, VirtualPath path, String pathTranslated, Boolean useAppConfig)
   at System.Web.HttpApplication.MapHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
The Zone of the assembly that failed was:
MyComputer 2017/07/17 09:43:25

同样,这一切都可以在生产服务器和十几个测试服务器中完美运行完全相同的代码。但是我们的生产支持服务器决定它只是不想再工作了。我正在寻找要检查的内容,以检查可能在 Web 或应用服务器上出现问题以导致上述错误。

远程配置(网络服务器)

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.runtime.remoting>
    <application>
      <channels>
        <channel ref="http" useDefaultCredentials="true" port="0">
          <clientProviders>
            <formatter ref="binary" typeFilterLevel="Full" />
          </clientProviders>
        </channel>
      </channels>
      <client url="http://10.10.10.10/AppServer">
        <activated type="MyApp.Common.Utilities,MyApp.Common" />
      </client>
    </application>
  </system.runtime.remoting>
</configuration>

WEBCONFIG(APP服务器)

<?xml version="1.0"?>
<configuration>
<system.runtime.remoting>
    <application>
      <service>
         <activated type="MyApp.Common.Utilities,MyApp.Common"/>      
      </service>
      <channels>
        <channel ref="http"/>
        <serverProviders>
          <formatter ref="binary" typeFilterLevel="Full" />
        </serverProviders>
      </channels>
    </application>
</system.runtime.remoting>
</configuration>

【问题讨论】:

  • 看起来远程处理工作,但它可能是导致错误的会话?

标签: .net-remoting


【解决方案1】:

此问题是由 New Relic 监控代理 v6 引起的。具体来说,一个新的 DLL 支持跟踪异步代码(New Relic 的代理以前不支持的东西)。

如果无法卸载代理或恢复到早期版本,则可以删除异步包装器 (C:\Program Files\New Relic.NET Agent\Extensions\NewRelic.Providers.CallStack.AsyncLocal.dll)。这将恢复 .NET Remoting 功能,但代价是 New Relic 无法在您的代码中检测异步方法。

【讨论】:

    【解决方案2】:

    经过 2 周的搜索,我们终于找到了问题所在。我们的运营团队安装了一些我认为是 New Relic 的监控软件。他们没有告诉任何人,也没有跟踪或告诉任何人他们在做什么。我们卸载了软件,环境恢复正常运行。当您同时对环境进行多项更改时,就会发生这种情况。您忘记了自己的所作所为以及导致环境恶化的原因。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-11-07
      • 2012-12-08
      • 2021-10-13
      • 2013-01-09
      • 2012-03-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多