Home : J-Integra for .NET : ERRMSG : RemoteException: Because of Security Restriction
Q141958 - ERRMSG: RemoteException: Because of Security Restriction

RemoteException: Because of Security Restriction

 

Contents

  1. SYMPTOMS
  2. CAUSE
  3. RESOLUTION

SYMPTOMS

Server Exception:

 

CAUSE

With the introduction of version 1.1 of the .NET Framework, a number of Remoting-related changes have been made. Most of them are focused at increasing security of .NET applications. If you use client activated objects, events or delegates you will quite likely encounter this exception when running on the .NET Framework 1.1.

Generally you see this error because you are trying to pass a type with the wrong typeFilterLevel. You need to have typeFilterLevel set both on the server and the client because communications are in both directions.

RESOLUTION

To change the security level to allow passing of delegates and object references over Remoting boundaries, you have to change the so called "typeFilterLevel".

Note: This problem is ONLY related to the .NET Framework 1.1. Do NOT set typeFilterLevel if you use .NET Framework 1.0.

You can do this either by using a configuration file like this (for server side):
<configuration>
  <system.runtime.remoting>
    <application>
      <channels>
        <channel ref="tcp" port="1234">
          <serverProviders>
            <formatter ref="binary" typeFilterLevel="Full" />
          </serverProviders>
          <clientProviders>
            <formatter ref="binary" />
          </clientProviders>
        </channel>
      </channels>
      <service>
        <!-- ... Add your services here ... -->
      </service>
    </application>
  </system.runtime.remoting>
</configuration>

In this case, a matching client-side configuration file which allows the reception of events and callbacks, would look like this:
  <system.runtime.remoting>
    <application>
      <channels>
        <channel ref="tcp" port="0">
          <clientProviders>
            <formatter ref="binary" />
          </clientProviders>
          <serverProviders>
            <formatter ref="binary" typeFilterLevel="Full" />
          </serverProviders>
        </channel>
      </channels>
      <client>
        <!-- ... Add your classes here ... -->
      </client>
    </application>
  </system.runtime.remoting>
</configuration>

If you prefer to setup your channels in source code, you have to use the extended constructor of the HttpChannel or TcpChannel to pass a custom IFormatterSinkProvider object:

BinaryServerFormatterSinkProvider serverProv = new BinaryServerFormatterSinkProvider();
provider.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;
BinaryClientFormatterSinkProvider clientProv = new BinaryClientFormatterSinkProvider();
IDictionary props = new Hashtable();props["port"] = 1234;
TcpChannel chan = new TcpChannel(props, clientProv, provider);
ChannelServices.RegisterChannel( chan );

Status

This does not require any fixes to J-Integra for .NET.

Related Articles
No Related Articles Available.

Article Attachments
No Attachments Available.

Related External Links
No Related Links Available.
Help us improve this article...
What did you think of this article?

poor 
1
2
3
4
5
6
7
8
9
10

 excellent
Tell us why you rated the content this way. (optional)
 
Approved Comments...
No user comments available for this article.
Created on 6/23/2006.
Last Modified on 7/10/2006.
Last Modified by No Author Name Available!.
Article has been viewed 7740 times.
Rated 0 out of 10 based on 0 votes.
Print Article
Email Article