Есть проект, написанный с использование технологии .NET Remoting. Сервер время от времени шлет широковещательные event подсоединенным клиентам. Если в параметрах делегата события используется базовый класс, то евент благополучно доходит до всех клиентов. Стоит в параметрах делегата поставить свой класс ([Serializable], наследован от MarshalByRefObject), при отсылке события клиенту возникает ошибка
"Because of security restrictions, the type System.Runtime.Remoting.ObjRef cannot be accessed.", как если бы в конфиге не был указан typeFilterLevel="Full" (хотя на клиенте он действительно не указан, так как там это не допускается вроде как). Возможно ли в параметрах события передать сложный класс. Исходники тестового приложения для работы с событиями и этой проблемой прилагаю. Ошибка возникает в файле General.cs на 61 строчке.
http://www.rsdn.ru/File/37455/events.rar
Серверная конфига:
<configuration>
<system.runtime.remoting>
<application>
<service>
<activated type="General.TapiServer, General" />
<wellknown mode="Singleton" type="General.Broadcaster, General" objectUri="Broadcaster.soap" />
</service>
<channels>
<channel ref="http" port="5555">
<serverProviders>
<formatter ref="soap" typeFilterLevel="Full" />
<formatter ref="binary" typeFilterLevel="Full" />
</serverProviders>
<clientProviders>
<formatter ref="binary" />
</clientProviders>
</channel>
</channels>
</application>
</system.runtime.remoting>
</configuration>
Клиентская конфига:
<configuration>
<appSettings>
<add key="RemoteClientActivatedServiceUrl" value="http://90.0.0.10:5555"/>
</appSettings>
<system.runtime.remoting>
<application>
<channels>
<channel ref="http" port="0" >
<clientProviders>
<formatter ref="binary" />
</clientProviders>
</channel>
</channels>
<client>
<wellknown type="General.IBroadcaster, General" url="http://90.0.0.10:5555/Broadcaster.soap" />
</client>
</application>
</system.runtime.remoting>
</configuration>
Кусок general.cs в котором возникает ошибка:
protected void SafeInvokeEvent(String msg)
{
// call the delegates manually to remove them if they aren't
// active anymore.
if (MessageArrived == null)
{
Console.WriteLine("No listeners");
}
else
{
Console.WriteLine("Number of Listeners: {0}",
MessageArrived.GetInvocationList().Length);
MessageArrivedHandler mah = null;
foreach (Delegate del in MessageArrived.GetInvocationList())
{
try
{
mah = (MessageArrivedHandler) del;
!!!! mah(msg, new Args(5));
}
catch (Exception e)
{
Console.WriteLine("Exception occured, will remove Delegate");
Console.WriteLine(e.Message);
MessageArrived -= mah;
}
}
}
}