Sign in to follow this  

Managed Direct3D Serializtion issues

This topic is 4224 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Has anyone ever run into this error before? Serialization will not deserialize delegates to non-public methods. Server stack trace: at System.DelegateSerializationHolder.GetDelegate(DelegateEntry de) at System.DelegateSerializationHolder.GetRealObject(StreamingContext context) at System.Runtime.Serialization.ObjectManager.ResolveObjectReference(ObjectHolder holder) at System.Runtime.Serialization.ObjectManager.DoFixups() at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck, IMethodCallMessage methodCallMessage) at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, IMethodCallMessage methodCallMessage) at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck) at System.Runtime.Remoting.Channels.CrossAppDomainSerializer.DeserializeObject(MemoryStream stm) at System.Runtime.Remoting.Channels.CrossAppDomainSerializer.DeserializeMessageParts(MemoryStream stm) at System.Runtime.Remoting.Messaging.SmuggledMethodCallMessage.FixupForNewAppDomain() at System.Runtime.Remoting.Channels.CrossAppDomainSink.DoDispatch(Byte[] reqStmBuff, SmuggledMethodCallMessage smuggledMcm, SmuggledMethodReturnMessage& smuggledMrm) at System.Runtime.Remoting.Channels.CrossAppDomainSink.DoTransitionDispatch(Byte[] reqStmBuff, SmuggledMethodCallMessage smuggledMcm, SmuggledMethodReturnMessage& smuggledMrm) 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 Microsoft.DirectX.Direct3D.Device.add_DeviceLost(EventHandler eh) at Microsoft.DirectX.Direct3D.VertexBuffer.CreateObject(IDirect3DVertexBuffer9* lp, Type typeVertexType, Int32 iNumVerts, Device device, Usage usage, VertexFormats vertexFormat, Pool pool, Boolean createNewObject, Boolean firstCreate) at Microsoft.DirectX.Direct3D.VertexBuffer..ctor(Type typeVertexType, Int32 numVerts, Device device, Usage usage, VertexFormats vertexFormat, Pool pool) at Tester.Tester..ctor(Device d3dDevice) I get his error when I try to create a VertexBuffer object within a C# object that is in a different Application Domain than the one where the Managed Direct3D Device originally came from. I originally ran into this error Remoting cannot find field m_lpUM on type Microsoft.DirectX.Direct3D.Device. Server stack trace: at System.Object.GetFieldInfo(String typeName, String fieldName) at System.Object.FieldGetter(String typeName, String fieldName, Object& val) at System.Runtime.Remoting.Messaging.StackBuilderSink.PrivateProcessMessage(MethodBase mb, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs) at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg, Int32 methodPtr, Boolean fExecuteInContext) 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.Object.FieldGetter(String typeName, String fieldName, Object& val) at Microsoft.DirectX.Direct3D.VertexBuffer.CreateObject(IDirect3DVertexBuffer9* lp, Type typeVertexType, Int32 iNumVerts, Device device, Usage usage, VertexFormats vertexFormat, Pool pool, Boolean createNewObject, Boolean firstCreate) at Microsoft.DirectX.Direct3D.VertexBuffer..ctor(Type typeVertexType, Int32 numVerts, Device device, Usage usage, VertexFormats vertexFormat, Pool pool) at Tester.Tester..ctor(MDX d3dHandle) However, I fixed this issue by writing a wrapper class around my Device Object that extends the RealProxy class. In this wrapper class I override the Invoke method to check and see if the FieldGetter method is called. The code looks something like this: public override IMessage Invoke(IMessage msg) { IMethodCallMessage call = (IMethodCallMessage) msg; return ExecuteMessage( call ); } public unsafe IMethodReturnMessage ExecuteMessage( IMethodCallMessage call ) { if( call.MethodName == "FieldGetter" && call.InArgCount > 2 && ((string)call.InArgs[1]) == "m_lpUM" ) { Type type = typeof(Device); FieldInfo info = type.GetField( "m_lpUM", BindingFlags.NonPublic | BindingFlags.Instance); object retval = info.GetValue( target ); unsafe { void* rawptr = System.Reflection.Pointer.Unbox( retval ); IntPtr ptr = new IntPtr( rawptr ); return new ReturnMessage( typeof(void), new object[]{null,null,ptr}, 3, call.LogicalCallContext, call ); } } else { return RemotingServices.ExecuteMessage( target, call ); } } If anyone can offer any insight on this that would great.

Share this post


Link to post
Share on other sites

This topic is 4224 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this