-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Serialization of IDictionary property causes exception
PostPosted: Tue Dec 18, 2007 4:16 pm 
Newbie

Joined: Fri Jun 30, 2006 3:44 pm
Posts: 4
Hi all,

I've been battling with this problem for a while and I'm pretty sure I have it nailed down to serializing an IDictionary. I have a nhibernate object that has an IDictionary property. I have a data access class which I am using via remoting (I am using Spring.NET to configure the remoting). I can load my object in the clinet application, however when I try to send the same object back to the server as a parameter to another method I get a reflection permissions problem.

Some details:
On my Product class I believe this is the offending property
Code:
  /// <summary>
        /// Gets or sets the ProductSpecifications for the current Product
      /// </summary>
        public virtual IDictionary ProductSpecifications
        {
            get { return this.productSpecifications; }
            set { this.productSpecifications = value; }
        }     


and the mapping looks like this
Code:
<map name="ProductSpecifications" lazy="true" inverse="true" cascade="all">
        <key column="ProductId" />
        <index-many-to-many column="SpecificationGroupSpecificationId" class="SpecificationGroupSpecification"/>
        <one-to-many class="ProductSpecification"/>
      </map>


In the client ProductService is a remoting service:
Code:
Product product = ProductService.GetProductByProductId(370);
ProductService.GetVendorProductByProduct(product);


The first line executes fine and returns me a usable object, however the second line throws the following exception.

Code:
Server stack trace:
   at System.RuntimeMethodHandle._SerializationInvoke(Object target, SignatureStruct& declaringTypeSig, SerializationInfo info, StreamingContext context)
   at System.RuntimeMethodHandle.SerializationInvoke(Object target, SignatureStruct declaringTypeSig, SerializationInfo info, StreamingContext context)
   at System.Reflection.RuntimeConstructorInfo.SerializationInvoke(Object target, SerializationInfo info, StreamingContext context)
   at System.Runtime.Serialization.ObjectManager.CompleteISerializableObject(Object obj, SerializationInfo info, StreamingContext context)
   at System.Runtime.Serialization.ObjectManager.FixupSpecialObject(ObjectHolder holder)
   at System.Runtime.Serialization.ObjectManager.DoFixups()
   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 BeforeYouBuy.Services.Interfaces.IProductService.GetVendorProductByProduct(Product product)
   at ConsoleApplication1.Program.Run() in C:\svn\ConsoleApplication1\Program.cs:line 51
   at ConsoleApplication1.Program.Main(String[] args) in C:\svn\ConsoleApplication1\Program.cs:line 37


Inner exception
Code:
   at System.Security.CodeAccessSecurityEngine.SpecialDemand(PermissionType whatPermission, StackCrawlMark& stackMark)
   at System.Security.CodeAccessPermission.DemandInternal(PermissionType permissionType)
   at System.Reflection.Emit.AssemblyBuilder.DefineDynamicModule(String name, Boolean emitSymbolInfo)
   at Castle.DynamicProxy.Builder.CodeGenerators.ModuleScope.CreateModule(Boolean signStrongName)
   at Castle.DynamicProxy.Builder.CodeGenerators.ModuleScope.ObtainDynamicModule(Boolean signStrongName)
   at Castle.DynamicProxy.Builder.CodeBuilder.EasyType..ctor(ModuleScope modulescope, String name, Type baseType, Type[] interfaces, Boolean serializable)
   at Castle.DynamicProxy.Builder.CodeGenerators.BaseCodeGenerator.CreateTypeBuilder(String typeName, Type baseType, Type[] interfaces)
   at Castle.DynamicProxy.Builder.CodeGenerators.ClassProxyGenerator.GenerateCode(Type baseClass, Type[] interfaces)
   at Castle.DynamicProxy.Serialization.ProxyObjectReference.RecreateClassProxy(SerializationInfo info, StreamingContext context)
   at Castle.DynamicProxy.Serialization.ProxyObjectReference.RecreateProxy(SerializationInfo info, StreamingContext context)
   at Castle.DynamicProxy.Serialization.ProxyObjectReference..ctor(SerializationInfo info, StreamingContext context)


And if any one is still reading - I've tried signing my entities assembly and adding the AllowParitallyTrustedCallers attribute but that didn't help.

If anyone can help me out here I would be extremely grateful!

Thanks,
Roboguy[/code]


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.