System.Runtime.Serialization.SerializationException: Because of security restrictions, the t
I have this .NET Remoting stuff i'm currently trying for my company since we have an idea of using .NET Remoting in the next version of our application. The basic is a windows form application as client and IIS as host for our objects. After i have been through several examples, guide, tutorials and so on i got it to work, but nothing lasts forever. When i bind the List<T> i get from our remoting to a BindingSource i get an exception in my Dispose on the form every time i try to close my window.
The layout of my form is very very simple a form (offcourse), a bindingsource, and a datagridview.
My form:
public partial class Form1 : Form public Form1() RemotingConfiguration.Configure( "SimpleFormClient.exe.config", false ); service = new ServiceClass( ); private void Form1_Load( object sender, EventArgs e ) bindingSource1.DataSource = tList;
{
ServiceClass service;
List<Tags> tList = null;
{
InitializeComponent( );
}
{
tList = service.GetAllTags();
}
}
App.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.runtime.remoting>
<application>
<channels>
<channel ref="http" useDefaultCredentials="true" port="0">
<clientProviders>
<formatter ref="binary" typeFilterLevel="Full" />
</clientProviders>
</channel>
</channels>
<client>
<wellknown url="http://localhost/Remoting/SAService.rem" type="ServiceClass, ServiceClass" />
</client>
</application>
</system.runtime.remoting>
</configuration>
Server is simple as far as i can see
web.config is like:
<configuration>
<system.runtime.remoting>
<application>
<service>
<wellknown mode="SingleCall" objectUri="SAService.rem" type="ServiceClass, ServiceClass"/>
</service>
<channels>
<channel name="http ServiceClass" ref="http">
<serverProvider>
<formatter ref="binary" typeFilterLevel="Full" />
</serverProvider>
</channel>
</channels>
</application>
</system.runtime.remoting>
</configuration>
The problem is now that i get following exception, and i have not been able to find any answers to my questions anywhere
See the end of this message for details on invoking ************** Exception Text ************** The demand was for: The only permitted permissions were: The method that caused the failure was: Server stack trace: Exception rethrown at [0]: ************** Loaded Assemblies ************** ************** JIT Debugging ************** For example: <configuration> When JIT debugging is enabled, any unhandled exception
just-in-time (JIT) debugging instead of this dialog box.
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"/>
<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>
<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>
System.Runtime.Remoting.Channels.ServerProcessing ProcessMessage(System.Runtime.Remoting.Channels.IServerChannelSinkStack, System.Runtime.Remoting.Messaging.IMessage, System.Runtime.Remoting.Channels.ITransportHeaders, System.IO.Stream, System.Runtime.Remoting.Messaging.IMessage ByRef, System.Runtime.Remoting.Channels.ITransportHeaders ByRef, System.IO.Stream ByRef)
End of inner exception stack trace
at System.Runtime.Serialization.FormatterServices.GetSafeUninitializedObject(Type type)
at System.Runtime.Serialization.Formatters.Binary.ObjectReader.ParseObject(ParseRecord pr)
at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Parse(ParseRecord pr)
at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.ReadObjectWithMapTyped(BinaryObjectWithMapTyped record)
at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.ReadObjectWithMapTyped(BinaryHeaderEnum binaryHeaderEnum)
at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.Run()
at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
at System.Runtime.Remoting.Channels.CoreChannel.DeserializeBinaryRequestMessage(String objectUri, Stream inputStream, Boolean bStrictBinding, TypeFilterLevel securityLevel)
at System.Runtime.Remoting.Channels.BinaryServerFormatterSink.ProcessMessage(IServerChannelSinkStack sinkStack, IMessage requestMsg, ITransportHeaders requestHeaders, Stream requestStream, IMessage& responseMsg, ITransportHeaders& responseHeaders, Stream& responseStream)
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at DomainObjects.Facade.Domain.PersistableObject.Equals(Object obj)
at System.Collections.Hashtable.KeyEquals(Object item, Object key)
at System.Collections.Hashtable.get_Item(Object key)
at System.ComponentModel.PropertyDescriptor.RemoveValueChanged(Object component, EventHandler handler)
at System.ComponentModel.ReflectPropertyDescriptor.RemoveValueChanged(Object component, EventHandler handler)
at System.Windows.Forms.BindingSource.UnwirePropertyChangedEvents(Object item)
at System.Windows.Forms.BindingSource.Dispose(Boolean disposing)
at System.ComponentModel.Component.Dispose()
at System.ComponentModel.Container.Dispose(Boolean disposing)
at System.ComponentModel.Container.Dispose()
at SimpleFormClient.Form1.Dispose(Boolean disposing) in C:\Projects\dotNET ObjectBinding\DObjTest\SimpleFormClient\Form1.Designer.cs:line 18
at System.ComponentModel.Component.Dispose()
at System.Windows.Forms.Form.WmClose(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
mscorlib
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
-
SimpleFormClient
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: file:///C:/Projects/dotNET%20ObjectBinding/DObjTest/SimpleFormClient/bin/Debug/SimpleFormClient.exe
-
System.Windows.Forms
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
-
System
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
-
System.Drawing
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
-
ObjHandling
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: file:///C:/Projects/dotNET%20ObjectBinding/DObjTest/SimpleFormClient/bin/Debug/ObjHandling.DLL
-
DomainObjects.Core
Assembly Version: 1.0.1.0
Win32 Version: 1.0.1.0
CodeBase: file:///C:/Projects/dotNET%20ObjectBinding/DObjTest/SimpleFormClient/bin/Debug/DomainObjects.Core.DLL
-
System.Configuration
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Configuration/2.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
-
System.Xml
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll
-
ServiceClass
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: file:///C:/Projects/dotNET%20ObjectBinding/DObjTest/SimpleFormClient/bin/Debug/ServiceClass.DLL
-
System.Runtime.Remoting
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Runtime.Remoting/2.0.0.0__b77a5c561934e089/System.Runtime.Remoting.dll
-
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.
<system.windows.forms jitDebugging="true" />
</configuration>
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.
I haven't got a clue why this fails except that it is probably something about rights but every where i search for answers i only get posts about typeFilterLevel i .net 1.1, but i got that sorted out and i am running 2.0.

