I am in over my head I think, I've got my brain running in circles trying to
figure this out.
I'm using remoting with a client and a server. I need the server to raise
events on the client and after doing quite a bit of reading I found what I
think is the correct way. The article I read encourages shims to pass the
delegate to server and back so that the client process doesn't need to be
passed. I barely understand it, I will understand more when I get it
working.
Anyway, these "Shim" classes in the example were tied to a specific delegate
and I wanted to create something a little more generic and reusable.
Here is the code I'm having trouble with:
<code>
// From the client
EventShimWithArgs<int[]>.Create(new
EventHandler<EventArgs<int[]>>(OnSomething));
// EventArgs <T>
public class EventArgs<T: EventArgs
{
private T _data;
public EventArgs(T data)
{
_data = data;
}
public T Data
{
get { return _data; }
}
}
// On the server
public class EventShimWithArgs<T: MarshalByRefObject
{
private EventHandler<EventArgs<T>target;
private EventShimWithArgs(EventHandler<EventArgs<T>target)
{
this.target += target;
}
public void Rar<T>(object sender, EventArgs<TeventArgs)
{
target(this, eventArgs);
}
public static EventHandler<EventArgs<T>>
Create<T>(EventHandler<EventArgs<T>target)
{
EventShimWithArgs<Tshim = new EventShimWithArgs<T>(target);
return new EventHandler<EventArgs<T>>( shim.Rar<T);
}
}
</code>
The line that is giving me my last compiler error is:
target(this, eventArgs);
The error is:
<error>
cannot convert from
'PMD.OfficeStudio.Infrastructure.Interface.EventAr gs<T>
[c:\PMDRepository\Tools\OfficeStudio\Source\Infrast ructure\Infrastructure.Interface\bin\Debug\Infrast ructure.Interface.dll]'
to
'PMD.OfficeStudio.Infrastructure.Interface.EventAr gs<T>
[c:\PMDRepository\Tools\OfficeStudio\Source\Infrast ructure\Infrastructure.Interface\bin\Debug\Infrast ructure.Interface.dll]'
C:\PMDRepository\Tools\OfficeStudio\Server\OfficeS tudioServerInterfaces\EventShimWithArgs.cs
OfficeStudioServer.Interface 23 26
</error>
Now... it's complaining about not being able to convert by the types it says
it can't covert are the SAME!
I'm stumped, anyone see the problem?
Thanks for any help!
Steve