Domanda

Si tratta di un problema quando si utilizza NHibernate con Remoting in una macchina con piena fiducia ambiente (in realtà di quella nostra macchina dev).

Il problema si verifica quando whe tenta di inviare come parametro un oggetto precedentemente recuperate dal server, che contiene un NHibernate proxy in una delle proprietà (uno artificiale).

Dato che siamo nella macchina dev, non c'è alcuna restrizione nel livello di fiducia della web app (è impostata su Totale) e, come un plus, abbiamo configurato assemblee di NHibernate e Castel alla piena fiducia nel CAS (pensando anche che non sarebbe necessario, come l'applicazione remoting in IIS è il livello di attendibilità completa).

Qualcuno ha qualche idea di ciò che può causare questa eccezione? analisi dello stack di seguito.

  InnerException: System.Security.SecurityException
   Message="Falha na solicitação da permissão de tipo 'System.Security.Permissions.ReflectionPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'."
   Source="mscorlib"
   GrantedSet=""
   PermissionState="<IPermission class=\"System.Security.Permissions.ReflectionPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\"\r\nversion=\"1\"\r\nFlags=\"ReflectionEmit\"/>\r\n"
   RefusedSet=""
   Url=""
   StackTrace:
        em System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet)
        em System.Security.CodeAccessPermission.Demand()
        em System.Reflection.Emit.AssemblyBuilder.DefineDynamicModuleInternalNoLock(String name, Boolean emitSymbolInfo, StackCrawlMark& stackMark)
        em System.Reflection.Emit.AssemblyBuilder.DefineDynamicModuleInternal(String name, Boolean emitSymbolInfo, StackCrawlMark& stackMark)
        em System.Reflection.Emit.AssemblyBuilder.DefineDynamicModule(String name, Boolean emitSymbolInfo)
        em Castle.DynamicProxy.ModuleScope.CreateModule(Boolean signStrongName)
        em Castle.DynamicProxy.ModuleScope.ObtainDynamicModuleWithWeakName()
        em Castle.DynamicProxy.ModuleScope.ObtainDynamicModule(Boolean isStrongNamed)
        em Castle.DynamicProxy.Generators.Emitters.ClassEmitter.CreateTypeBuilder(ModuleScope modulescope, String name, Type baseType, Type[] interfaces, TypeAttributes flags, Boolean forceUnsigned)
        em Castle.DynamicProxy.Generators.Emitters.ClassEmitter..ctor(ModuleScope modulescope, String name, Type baseType, Type[] interfaces, TypeAttributes flags, Boolean forceUnsigned)
        em Castle.DynamicProxy.Generators.Emitters.ClassEmitter..ctor(ModuleScope modulescope, String name, Type baseType, Type[] interfaces, TypeAttributes flags)
        em Castle.DynamicProxy.Generators.Emitters.ClassEmitter..ctor(ModuleScope modulescope, String name, Type baseType, Type[] interfaces)
        em Castle.DynamicProxy.Generators.BaseProxyGenerator.BuildClassEmitter(String typeName, Type parentType, Type[] interfaces)
        em Castle.DynamicProxy.Generators.BaseProxyGenerator.BuildClassEmitter(String typeName, Type parentType, IList interfaceList)
        em Castle.DynamicProxy.Generators.ClassProxyGenerator.GenerateCode(Type[] interfaces, ProxyGenerationOptions options)
        em Castle.DynamicProxy.Serialization.ProxyObjectReference.RecreateClassProxy()
        em Castle.DynamicProxy.Serialization.ProxyObjectReference.RecreateProxy()
        em Castle.DynamicProxy.Serialization.ProxyObjectReference..ctor(SerializationInfo info, StreamingContext context)

Grazie in anticipo.

È stato utile?

Soluzione

In realtà, io lavoro con Pedro, abbiamo trovato il problema:. Il serializzatore del servizio remoto deve essere esplicito configurato per consentire le chiamate di fiducia a pieno titolo nel lato server

Qualcosa di simile (file di configurazione):

<channels>
<channel ref="http">
<serverProviders> 
<provider ref="wsdl" />
<formatter ref="soap" typeFilterLevel=Low />
<formatter ref="binary" typeFilterLevel=Low />
</serverProviders>
</channel>
</channels>

Or (programatically):

BinaryServerFormatterSinkProvider provider = new BinaryServerFormatterSinkProvider();
provider.TypeFilterLevel = TypeFilterLevel.Full;

Spero che questo aiuti chiunque altro.

Saluti.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top