I am trying to remote and object over http channel using the SOAP
formatter so that I can add a web reference to my remoted object
allowing me to reference it from the compact framework.

http://www.dotnet247.com/247reference/msgs/17/88256.aspx

The problem I have is that the object I am remoting contains a number of
methods that return simple custom objects containing strings and arrays.

As soon as I declare an ArrayList in one of these custom classes the
whole lot compiles and I update my web reference, I cannot however
access the namespace, to get to the objects within the web reference,
let along call a method!!

I assume this is because the SOAP formatter will not serialize complex
objects (so ive read). So I put the  [NonSerialized]  attribute in front
of the ArrayList declaration, hopeing to handle the serialization myself
and serialize as an array.  But the soap formatter ignores the the
attribute!.

Some code taken from my solution
----------------------------------
This is the custom class being returned from the Remoted object. Its
basically mimicking a Directory structure where this is a directory and
it may contain multiple sub directories which are part of a
MediaDirectoryCollection.

[Serializable]
        public class MediaDirectory
        {
                private MediaDirectoryCollection m_objSubDirectories =
new MediaDirectoryCollection();

                public MediaDirectory()
                {}
        }

This is the MediaDirectoryCollection.  I know it could inherit from a
Collection class such as ListBase and DictionaryBase, but at this stage
I just want to remote the object and have tried so many things before
its ended up in this form.

        [Serializable]
        public class MediaDirectoryCollection : IDeserializationCallback
        {
                [NonSerialized]
                public ArrayList m_alValues = new ArrayList();

                public string s;

                public void OnDeserialization(object sender)
                {
                        m_alValues = new ArrayList();
                }


                public MediaDirectoryCollection()
                {
                }
        }

If I comment out the ArrayList decleration everything works fine, as
soon as I put it in and the wsdl generated contains the following lines,
then it doesn't work!!

<s:import
namespace="http://schemas.microsoft.com/clr/ns/System.Collections"; />

<s:element name="m_alValues"
xmlns:q1="http://schemas.microsoft.com/clr/ns/System.Collections";
type="q1:ArrayList" />


Can someone please shed some light onto
a) why I cant remote an ArrayList via SOAP over HTTP channel using
remoting?
b) why is it that the [NonSerialized] attribute is doing nothing!
And c) any suggestions as to what to do to fix this (short of declaring
arrays and handling the resize myself!!).

Thanks

Simon

Reply via email to