SerialisationException: Request for the permission of type <type> failed.
- From: jason.southgate@xxxxxxxxx
- Date: 17 Jul 2006 02:59:51 -0700
I'm getting a serialisation exception with an inner permission error
when running the following code:
using System;
using System.Data;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;
using System.Collections;
using System.Diagnostics;
using TSI.DRICE.Interfaces;
using TSI.DRICE.CustomerCarrier.BusinessLayer;
namespace Tsp.Drice.Remoting
{
/// <remarks>
/// Sample client to test DRICE .NET remoting
/// </remarks>
public class SampleClient
{
public static int Main(string [] args)
{
try
{
string ip;
if (args.Length==0) ip = "10.115.72.168";
else ip= args[0];
BinaryServerFormatterSinkProvider serverProv = new
BinaryServerFormatterSinkProvider();
serverProv.TypeFilterLevel =
System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;
BinaryClientFormatterSinkProvider clientProv = new
BinaryClientFormatterSinkProvider();
IDictionary props = new Hashtable();
props["port"] = 1234;
TcpChannel chan = new TcpChannel(props, clientProv, serverProv);
ChannelServices.RegisterChannel( chan );
IEngineFactory factory = (IEngineFactory) Activator.GetObject(
typeof( TSI.DRICE.Interfaces.IEngineFactory ),
"tcp://" + ip + ":60099/DRICE" );
if( factory.Equals(null) )
{
Console.WriteLine("Error: factory is null");
}
else
{
IEngine engine = factory.CreateEngine( EngineTypes.etPCMiler );
Console.WriteLine( engine.ApiVersion );
Console.WriteLine( engine.CalcDistance( "90210", "10001",
RouteTypes.rtPractical ).ToString() );
}
return 0;
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message);
Debug.WriteLine(ex.InnerException);
Debug.WriteLine(ex.StackTrace);
return 0;
}
}
}
}
On the server side, the TSI.DRICE.Interfaces.IEngineFactory is provided
as a singleton.
EngineTypes.etPCMiler is just a simple Enum, which is defined in
TSI.DRICE.Interfaces (available to both client and server).
Unhandled Exception:
System.Runtime.Serialization.SerializationException: Reques
t for the permission of type TSI.DRICE.Interfaces.EngineTypes failed.
---> Syste
m.Security.SecurityException: Request failed.
at
System.Security.SecurityRuntime.FrameDescSetHelper(FrameSecurityDescriptor
secDesc, PermissionSet demandSet, PermissionSet& alteredDemandSet)
at
System.Runtime.Serialization.FormatterServices.nativeGetSafeUninitializedO
bject(RuntimeType type)
at
System.Runtime.Serialization.FormatterServices.GetSafeUninitializedObject(
Type type)
--- End of inner exception stack trace ---
Server stack trace:
at
System.Runtime.Serialization.FormatterServices.GetSafeUninitializedObject(
Type type)
at
System.Runtime.Serialization.Formatters.Binary.ObjectReader.ParseObject(Pa
rseRecord pr)
at
System.Runtime.Serialization.Formatters.Binary.ObjectReader.Parse(ParseRec
ord pr)
at
System.Runtime.Serialization.Formatters.Binary.__BinaryParser.ReadObjectWi
thMapTyped(BinaryObjectWithMapTyped record)
at
System.Runtime.Serialization.Formatters.Binary.__BinaryParser.ReadObjectWi
thMapTyped(BinaryHeaderEnum binaryHeaderEnum)
at
System.Runtime.Serialization.Formatters.Binary.__BinaryParser.Run()
at
System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(He
aderHandler handler, __BinaryParser serParser, Boolean fCheck,
IMethodCallMessag
e methodCallMessage)
at
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize
(Stream serializationStream, HeaderHandler handler, Boolean fCheck,
IMethodCallM
essage methodCallMessage)
at
System.Runtime.Remoting.Channels.CoreChannel.DeserializeBinaryRequestMessa
ge(String objectUri, Stream inputStream, Boolean bStrictBinding,
TypeFilterLevel
securityLevel)
at
System.Runtime.Remoting.Channels.BinaryServerFormatterSink.ProcessMessage(
IServerChannelSinkStack sinkStack, IMessage requestMsg,
ITransportHeaders reques
tHeaders, Stream requestStream, IMessage& responseMsg,
ITransportHeaders& respon
seHeaders, Stream& responseStream)
Exception rethrown at [0]:
at
System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage
req
Msg, IMessage retMsg)
at
System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&
msgDa
ta, Int32 type)
at TSI.DRICE.Interfaces.IEngineFactory.CreateEngine(EngineTypes
aen_engine)
at Tsp.Drice.Remoting.SampleClient.Main(String[] args) in
d:\source\dricetest
er\dricetester\sampleclient.cs:line 49
After researching in usenet groups, I changed the code to set the
TypeFilterLevel to Full, but this makes no difference.
Any advice?
.
- Prev by Date: Cross-AppDomain remoting strangeness
- Next by Date: Problems with host headers in remoting
- Previous by thread: Cross-AppDomain remoting strangeness
- Next by thread: Problems with host headers in remoting
- Index(es):
Relevant Pages
|