RickKr

I'm trying to run the MSDN Remoting Example "Lifetimes". I created a solution with 3 projects, one each for the client, server, and remotable object, and copied in the code and config settings given in the example. I built them and started the server, then attempted to start the client. This is what I got:

Unhandled Exception: System.Runtime.Serialization.SerializationException: Because of security restrictions, the type System.Runtime.Remoting.ObjRef cannot be accessed. ---> System.Security.SecurityException: Request failed.
at System.Runtime.Serialization.FormatterServices.nativeGetSafeUninitializedObject(RuntimeType type)
at System.Runtime.Serialization.FormatterServices.GetSafeUninitializedObject(Type type)
The action that failed was:
Demand
The type of the first permission that failed was:
System.Security.Permissions.SecurityPermission
The first permission that failed was:
<IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
version="1"
Flags="Infrastructure"/>

The demand was for:
<PermissionSet class="System.Security.PermissionSet"
version="1">
<IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
version="1"
Flags="Infrastructure"/>
</PermissionSet>

The only permitted permissions were:
<PermissionSet class="System.Security.PermissionSet"
version="1">
<IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
version="1"
Flags="SerializationFormatter"/>
</PermissionSet>

The method that caused the failure was:
System.Runtime.Remoting.Channels.ServerProcessing ProcessMessage(System.Runtime.Remoting.Channels.IServerChannelSinkStack, System.Runtime.Remoting.Messaging.IMessage, System.R
untime.Remoting.Channels.ITransportHeaders, System.IO.Stream, System.Runtime.Remoting.Messaging.IMessage ByRef, System.Runtime.Remoting.Channels.ITransportHeaders ByRef, Syste
m.IO.Stream ByRef)
--- End of inner exception stack trace ---

Server stack trace:
at System.Runtime.Serialization.FormatterServices.GetSafeUninitializedObject(Type type)
at System.Runtime.Serialization.Formatters.Soap.ObjectReader.ParseObject(ParseRecord pr)
at System.Runtime.Serialization.Formatters.Soap.ObjectReader.Parse(ParseRecord pr)
at System.Runtime.Serialization.Formatters.Soap.SoapHandler.StartChildren()
at System.Runtime.Serialization.Formatters.Soap.SoapParser.ParseXml()
at System.Runtime.Serialization.Formatters.Soap.SoapParser.Run()
at System.Runtime.Serialization.Formatters.Soap.ObjectReader.Deserialize(HeaderHandler handler, ISerParser serParser)
at System.Runtime.Serialization.Formatters.Soap.SoapFormatter.Deserialize(Stream serializationStream, HeaderHandler handler)
at System.Runtime.Remoting.Channels.CoreChannel.DeserializeSoapRequestMessage(Stream inputStream, Header[] h, Boolean bStrictBinding, TypeFilterLevel securityLevel)
at System.Runtime.Remoting.Channels.SoapServerFormatterSink.ProcessMessage(IServerChannelSinkStack sinkStack, IMessage requestMsg, ITransportHeaders requestHeaders, Stream
requestStream, IMessage& responseMsg, ITransportHeaders& responseHeaders, Stream& responseStream)

Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at System.Runtime.Remoting.Lifetime.ILease.Register(ISponsor obj)
at Client.Main(String[] Args) in D:\VSSettings\Projects\Lifetimes\CAOClient\CAOClient.cs:line 23

What do I need to do to fix this

Thanks...Rick



Re: .NET Remoting and Runtime Serialization How can I handle the SerializationException for MSDN Remoting Example: Lifetimes?

Sowmy Srinivasan

Looks like the TypeFilterLevel is not set. Please post the pointer to the sample and I will ensure it is fixed. Manish had a good post on this at http://blogs.msdn.com/manishg/archive/2004/10/27/248841.aspx

I hope this helps.






Re: .NET Remoting and Runtime Serialization How can I handle the SerializationException for MSDN Remoting Example: Lifetimes?

RickKr

Thanks Sowmy. The sample link is in the original question--the word "LifeTimes" contains the link. But for ease of use, I'll repost it here without hiding it: http://msdn2.microsoft.com/en-us/library/6tkeax11.aspx.



Re: .NET Remoting and Runtime Serialization How can I handle the SerializationException for MSDN Remoting Example: Lifetimes?

RickKr

After reading Manish's blog and checking docs, it looks to me like the sample is all right in that regard. Here's the config file from the sample:

<configuration>
<system.runtime.remoting>
<application>
<client url="http://localhost:8080">
<activated type="ClientActivatedType, RemoteType"/>
</client>
<channels>
<channel ref="http" port="0">
<serverProviders>
<formatter ref="soap" typeFilterLevel="Full"/>
<formatter ref="binary" typeFilterLevel="Full"/>
</serverProviders>
</channel>
</channels>
</application>
</system.runtime.remoting>
</configuration>

Is there something else going on then