Administrator

Administrator

  • Tech Writer
  • 2.2k
  • 1.5m

Unmanaged client / Async delegates /RemotingException

Mar 31 2003 10:47 AM
I am having a System.Runtime.Remoting.RemotingException: "Cannot load type Testing.DelegateTest" problem calling a .NET assembly method from an unmanaged client if this method uses asynchronous delegates. Here are the steps: 1. Create a sample TestAssembly .NET assembly that is callable through COM interop. 2. Create a class that has 2 public methods: SyncOp and AsyncOp, where a SyncOp is a regular sync method and AsyncOp creates a delegate which takes SyncOp function pointer and then calls BeginInvoke() 3. SyncOp is return successfully. Calling AsyncOp throws a "Cannot load type Testing.DelegateTest" exception. Below I pasted: 1. Sample class DelegateTest 2. VB script that calls it 3. exception stack trace Has anyone run into this problem? Also, I created a C# client that does the same as VB script - it worked fine. DelegateTest class: <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< namespace Testing { [Guid("7121656d-e1a7-4484-8164-9e0f9c87cbc0")] public interface IDelegateTest { void SyncOp(); void AsyncOp(); } public delegate void AsyncDel(); [Guid("96c7714a-741c-4d6a-9b76-9bd47d5f35fb")] [ClassInterface(ClassInterfaceType.None)] public class DelegateTest : IDelegateTest { public void SyncOp() { } public void AsyncOp() { try { AsyncDel del = new AsyncDel(SyncOp); IAsyncResult res = del.BeginInvoke(null, null); } catch(Exception e) { Console.Out.WriteLine(e.ToString()); Console.Out.WriteLine(e.Message); Console.Out.WriteLine(e.StackTrace); } } } } <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< VB Script: <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< dim at set at = CreateObject("TestAssembly.DelegateTest") wscript.echo "Calling sync op" at.SyncOp() wscript.echo "Calling async op" at.AsyncOp() <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<