all groups > dotnet remoting > july 2004 >
You're in the

dotnet remoting

group:

Throwing exception remoting ArrayList?


Throwing exception remoting ArrayList? A. Burch
7/21/2004 2:00:25 PM
dotnet remoting:
I'm having a problem handling an ArrayList of object who content is 90
records of data items.. The code below demonstrates the exeception error.
The text of the error is the following......

"Recieve: The type Admins.BCBarData in Assembly TestClient, Version
1.0.1663.23136, Culture=neutral, PublicKeyToken=null is not marked as
serializable

----------------------------------------------------------------------------
---------------------------------------------------

This problem occurs for me in a much larger project I'm doing but this codes
demonstrates the problem. What is wrong and how do I fix it to be able to
set an array of objects that contain different element types without giving
me the exception errror?

----------------------------------------------------------------------------
---------------------------------------------------

Server Code
-----------------------------------------------------------
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Messaging;
namespace Admins
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
ArrayList BCStk = new ArrayList();
BinaryServerFormatterSinkProvider tpfProvider = new
BinaryServerFormatterSinkProvider();
tpfProvider.TypeFilterLevel =
System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;
BinaryClientFormatterSinkProvider clientProv = new
BinaryClientFormatterSinkProvider();
IDictionary props = new Hashtable();
props["port"] = 1313;
TcpChannel chnl = new TcpChannel(props, clientProv, tpfProvider);
ChannelServices.RegisterChannel(chnl);
Console.ReadLine();
}
}
}
----------------------------------------------------------
// Interface Code (definitions and function implementation
----------------------------------------------------------
// General - interface definition and function implementation

using System;
using System.Data;
using System.Collections;
namespace Admins
{
public abstract class BaseArrayRemoteObject : MarshalByRefObject
{
public abstract void setObject(ArrayList val);
public abstract ArrayList getObject();
}
public class TheBCRemoteObject : BaseArrayRemoteObject
{
protected static ArrayList gavalue;
public override void setObject(ArrayList val)
{
gavalue = val;
}
public override ArrayList getObject()
{
return(gavalue);
}
}
}
----------------------------------------------------------------------
// Client code - ArrayList remoting throws an execption???
-----------------------------------------------------------------------

using System;
using System.Collections;
using System.Data;
using System.Runtime.Remoting.Channels.Tcp;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Proxies;
using System.Messaging;
using System.Diagnostics;

namespace Admins
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
TcpChannel channel = new TcpChannel();
ChannelServices.RegisterChannel(channel);
try
{
BaseArrayRemoteObject bcobj = (BaseArrayRemoteObject)
Activator.GetObject(typeof
BaseArrayRemoteObject),
"tcp://localhost:1313/TheBCRemoteObject.soap");
ArrayList BCStk = new ArrayList();
BCStk.Clear();
BCStk.Add("HI");
// Set up an object of 1 element (string type) record
BCBarData bcqrec = new BCBarData();
bcqrec.Symbol = "DUM";
BCStk.Add(bcqrec);
bcobj.setObject(BCStk); //<<<<<<<<<<<< Exception is thrown
here<<<<<<<<<<<<<<<<<<<<<<<<<
bcqrec.Symbol = "BYE";
BCStk = bcobj.getObject();
Console.WriteLine("BCStk = {0}", BCStk[0].ToString());
Console.ReadLine();
}
catch (Exception ex)
{
Debug.WriteLine("Receive: " + ex.Message);
}
}
}
[System.Xml.Serialization.XmlRoot("ClassBCTypeBase")]
public class ClassBCTypeBase
{
}
[System.Xml.Serialization.XmlRoot("BCBarData")]
public class BCBarData : ClassBCTypeBase
{
public string Symbol;
}
}

Re: Throwing exception remoting ArrayList? Sunny
7/21/2004 4:30:13 PM
Hi,

you have to put BCBarData in the shared assembly with all other
interfaces. Now the server does not know anything about that class and
how to deserialize.

Sunny

In article <eWFUZX2bEHA.2972@TK2MSFTNGP12.phx.gbl>, a1_dog@msn.com
says...
[quoted text, click to view]
AddThis Social Bookmark Button