Jump to content
  • Advertisement
Sign in to follow this  
axv4745

Managed Direct3D Serializtion issues

This topic is 4442 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
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!