Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Unmanaged client / Async delegates /RemotingException

Status
Not open for further replies.

azazello

Programmer
Mar 31, 2003
1
US
Hello!
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 attached:

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(&quot;7121656d-e1a7-4484-8164-9e0f9c87cbc0&quot;)]
public interface IDelegateTest
{
void SyncOp();
void AsyncOp();

}
public delegate void AsyncDel();

[Guid(&quot;96c7714a-741c-4d6a-9b76-9bd47d5f35fb&quot;)]
[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(&quot;TestAssembly.DelegateTest&quot;)
wscript.echo &quot;Calling sync op&quot;
at.SyncOp()
wscript.echo &quot;Calling async op&quot;
at.AsyncOp()

<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top