SerialisationException: Request for the permission of type <type> failed.




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?

.



Relevant Pages

  • Re: System.Security.SecurityException was unhandled
    ... The exception gave you the CLSID. ... the first thing to check might be whether the COM server ... assembly actually has the permission in question. ... When I execute the application I received and error message. ...
    (microsoft.public.dotnet.security)
  • Re: error in accessing database
    ... Im using my account that is authenticated by the server ... I also check the permission of the folder, ... Access requires the creation of an .ldb file when the database ... An unhandled exception occurred during the execution of the ...
    (microsoft.public.dotnet.framework.aspnet)
  • Cant get OMA going
    ... I'm trying to setup OMA on my Exchange 2003 Standard server on a Windows ... To grant this application the required permission ... Exception Details: System.Security.SecurityException: Request for the ...
    (microsoft.public.exchange.clients)
  • Re: System.Security.SecurityException was unhandled
    ... assembly actually has the permission in question. ... I will send u the exception message later... ... On the server or the client? ... When I execute the application I received and error message. ...
    (microsoft.public.dotnet.security)
  • Filestream is not throwing exception when created for the same file - (async)
    ... I am downloading file from the server. ... using (Stream stream = res.GetResponseStream()) ... //the file stream doesn't throw any exception ...
    (microsoft.public.dotnet.languages.csharp)