   C# - Sharing a Managed Direct3D Device across Application Domains
  Does anyone know of any problems with using a Managed Direct3D Device Object across multiple Application Domains? I've been trying to create a VertexBuffer inside the constructor of an object that is in a different Application Domain than the main program but if fails. The main program passes a reference to a Direct3D Device to the Object that is in the different Applicaton Domain. I'd just like to know if there are known problems with sharing a D3D Device across multiple Application Domains.This is the specific exception I am getting:    "Operation is not valid due to the current state of the object."this occurs when I try to fill the Vertex Buffer with data. I wasn't getting this error until I started dealing with sharing a Direct3D device across multiple Application Domains. Any insight would be greatly appreciated.Thanks,   
  Well, I know that there are problems with using a device across threads, and an app domain would fall under that. You could setup the device for multi threading, but there is a lot of overhead. Your best bet is to send back your vertex data from the other app and fill in the buffer OR lock the buffer, hand the pointers off to the other app, wait for it to finish, then lock the buffer and continue.   ;  Thanks for the insight Mite51. Is it possible thats its more of an issue with respect to serialization that threading? I know when you usually deal with sharing objects across app domains you have to marshal the object to the other app domain, which usually involves elements of serialization. A previous error I recieved when attempting to make the Vertex Buffer was   "Serialization will not deserialize delegates to non-public methods."However I worked around this problem by wrapping the device into another object and passing the reference to this object to the Object that was in the other app domain. Then (in the object that was in the other app domain) I made calls to the reference that was passed in to generate a vertex buffer. Essentially I was wrapping the call to create a vertexBuffer within another function call, which worked for a little while until the Error I described in the first post appeared. I feel that ultimately its an inherent issue with the Direct3D devices not working properly across app domains but I'm looking for any specific known issues.   ;  I think that the serialization error had less to do with DX and more to do with .NET, maybe in the the managedDX wrapper, maybe just how you were using the objects involved, I couldnt tell you for sure. Try creating your device with D3DCREATE_MULTITHREADED as see what happens... I still think you would be better off building your vertex buffer ( as a System.Collection.List of points, indexes and UVS ) in the other thread then pass them back to the thread with the device for dumping into a buffer.   ;  While I don't know enough about the specifics of the implementation of MDX (although I know a thing or two about remoting, which is what any communication between appdomains will use), I'm fairly sure this is a Bad Idea. Would you try to run a DirectX app distributed across multiple applications?   