System.Runtime.Serialization.SerializationException: Because of security restrictions,

Posts   
 
    
Jayro
User
Posts: 14
Joined: 15-Nov-2006
# Posted on: 20-Jun-2007 20:07:23   

most of the advice on the topic refers to adding the typeFilterLevel="Full" to my config, and I have done that, and the error still persists. Perhaps I am missing something obvious. Any help would be appreciated.

Web.Config


<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
    <configSections>
        <section name="sqlServerCatalogNameOverwrites" type="System.Configuration.NameValueSectionHandler"/>
    </configSections>
    <sqlServerCatalogNameOverwrites>
        <add key="ReportBuilder3" value="reportbuilder3"/>
        <add key="BHW_Auth" value="reportbuilder3"/>
    </sqlServerCatalogNameOverwrites>
    <appSettings>
        <add key="Main.ConnectionString" value="data source=10.0.0.11;initial catalog=reportbuilder3;User ID=sa;Password=qpalzm;persist security info=False;packet size=4096;Connection Timeout=30" />
    </appSettings>
    <system.runtime.remoting>
        <application>
            <service>
                <wellknown mode="SingleCall" objectUri="SAService.rem" type="ServiceClass, Service"/>
            </service>
            <channels>
                <channel name="http ServiceClass" ref="http">
                    <serverProvider>
                        <formatter ref="binary" typeFilterLevel="Full" />
                    </serverProvider>
                    <clientProviders>
                        <formatter ref="binary" />
                    </clientProviders>
                </channel>
            </channels>
        </application>
    </system.runtime.remoting>
</configuration>

Service Class


using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Threading;
using System.Web;

public interface IService
{
   DateTime GetServerTime();
   string GetServerString();
}

// IService exists to demonstrate the possibility of publishing only the interface.
public class ServiceClass : MarshalByRefObject, IService
{
   private int InstanceHash;

   public ServiceClass()
   {
      InstanceHash = this.GetHashCode();
   }

    public DateTime GetServerTime()
    {
        return DateTime.Now;
    }

    public string GetServerString()
    {
        // Use the HttpContext to acquire what IIS thinks the client's identity is.
        string temp = HttpContext.Current.User.Identity.Name;
        if (temp == null || temp.Equals(string.Empty))
            temp = "**unavailable**";
        return "Hi there. You are being served by instance number: " 
         + InstanceHash.ToString() 
         + ". Your alias is: " 
         + temp;
    }

    public void FetchEntity(SD.LLBLGen.Pro.ORMSupportClasses.IEntity2 entity)
    {
        VTRemote.Data.DatabaseSpecific.DataAccessAdapter adapter = new VTRemote.Data.DatabaseSpecific.DataAccessAdapter();
        adapter.SaveEntity(entity);
    }

    //public SD.LLBLGen.Pro.ORMSupportClasses.IEntity2 FetchEntity(SD.LLBLGen.Pro.ORMSupportClasses.IEntity2 entity)
    //{
        
    //  VTRemote.Data.DatabaseSpecific.DataAccessAdapter adapter = new VTRemote.Data.DatabaseSpecific.DataAccessAdapter();
    //  adapter.FetchEntity(entity);
    //  return;
    //}
}

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"
                  />
                    </clientProviders>
                    <serverProviders>
                        <formatter ref="binary" typeFilterLevel="Full" />
                    </serverProviders>
                </channel>
            </channels>
            <client>
                <wellknown
                   url="http://127.0.0.1:80/VTRemotePromo/SAService.rem"
                   type="ServiceClass, Service"
            />
            </client>
        </application>
    </system.runtime.remoting>
</configuration>

Client.exe code


using System;
using System.Collections;
using System.Net;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Security.Principal;
namespace Client
{
    class Program
    {
        public static void Main(string[] args)
        {
            // Tells the system about the remote object and customizes the HttpChannel
            // to use the binary formatter (which understands that base64 encoding is needed).
            RemotingConfiguration.Configure(@"C:\BHW Projects\RemotingTest\Client\bin\Debug\Client.exe.config", false);

            // New proxy for the ServiceClass.
            // If you publish only the IService interface, you must use Activator.GetObject.
            ServiceClass service = new ServiceClass();

            // Programmatically customizes the properties given to the channel. This sample uses the
            // application configuration file.
            IDictionary Props = ChannelServices.GetChannelSinkProperties(service);
            Props["credentials"] = CredentialCache.DefaultCredentials;

            // Reports the client identity name.
            Console.WriteLine("ConsoleIdentity: " + WindowsIdentity.GetCurrent().Name);

            // Writes what the server returned.
            Console.WriteLine("The server says : " + service.GetServerString());
            Console.WriteLine("Server time is: " + service.GetServerTime());

            VTRemote.Data.EntityClasses.RoleEntity roleEntity = new VTRemote.Data.EntityClasses.RoleEntity();

            roleEntity.Name = "Sent via remoting bitches!!!";
            roleEntity.Description = "Sent via remoting bitches!!!";

            Console.WriteLine(roleEntity.Id.ToString());
            service.FetchEntity(roleEntity);
            Console.WriteLine(roleEntity.Id.ToString());

        }
    }
}

Running on .Net 2.0 Visual Studio 2..5, hosting inside IIS. Using LLBL version 2.0.0.0 Adapter Model

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39912
Joined: 17-Aug-2003
# Posted on: 20-Jun-2007 22:30:48   
Frans Bouma | Lead developer LLBLGen Pro
Jayro
User
Posts: 14
Joined: 15-Nov-2006
# Posted on: 20-Jun-2007 22:37:25   

Otis wrote:

http://www.thinktecture.com/resourcearchive/net-remoting-faq/changes2003

as noted above, I already have the typeFilterLevel="Full" set. So, this is not the problem. Also, I am using a binary package, so the soapsuds aspect of the article is irrelevant, and the config aspect is useless. Would you mind taking a second look and let me know what I am doing wrong?

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 21-Jun-2007 11:31:59   

I'm not sure ab out the cause of this, but here are some similar threads that might be helpful: http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=4853 http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=5004