[Mono-bugs] [Bug 469198] New: Remoting problem: Object type System.Int64 cannot be converted to target type System.Int32

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Sat Jan 24 14:14:00 EST 2009


https://bugzilla.novell.com/show_bug.cgi?id=469198


           Summary: Remoting problem: Object type System.Int64 cannot be
                    converted to target type System.Int32
    Classification: Mono
           Product: Mono: Runtime
           Version: 2.2.x
          Platform: 64bit
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: remoting
        AssignedTo: lluis at novell.com
        ReportedBy: inschenjoer at gmx.de
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---


The serverside was tested with mono 1.9 on debian lenny, mono 2.2 with the mono
vmware image, Windows XP32bit and Windows Vista 64bit with the Microsoft .Net
Framework.
The client-side was running Windows XP 32bit and Windows Vista 64bit with the
Microsoft .Net Framework.

The problem occures only if the client is running on Windows Vista 64bit and
the server on Mono 32bit.

So I think its a problem with mono running 32bit and the client is running
64bit. 

Here is an example of the server:
=========================

using System;
using System.Collections.Generic;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;

namespace RemotingServer
{
    public class Program
    {
        static void Main(string[] args)
        {
            Dictionary<string, object> dict = new Dictionary<string, object>();
            dict["name"] = "ServerChannel";
            dict["port"] = 5001;
            dict["typeFilterLevel"] = "Full";

            // create the server channel
            TcpChannel server_channel = new TcpChannel(dict, null, null);

            ChannelServices.RegisterChannel(server_channel, false);

            RemotingServices.Marshal(new SessionFactory(), "SessionFactory");

            Console.WriteLine("Press key to exit the application ...");
            Console.ReadLine();
        }
    }

    public class SessionFactory : MarshalByRefObject
    {
        public override object InitializeLifetimeService()
        {
            return null;
        }

        public SessionObject Login()
        {
            return new SessionObject();
        }
    }

    public class SessionObject : MarshalByRefObject
    {
        protected ApplicationClient m_client = null;

        public ApplicationClient ApplicationClient
        {
            get { return m_client; }
            set { m_client = value; }
        }
    }

    public class ApplicationClient : MarshalByRefObject
    {
        public ApplicationClient()
        {
            // den ClientChannel registrieren
            ChannelServices.RegisterChannel(new TcpChannel(), false);
        }

        public SessionObject Login(string hostname)
        {
            SessionFactory factory =
(SessionFactory)Activator.GetObject(typeof(SessionFactory),
string.Format("tcp://{0}:5001/SessionFactory", hostname));

            SessionObject session = factory.Login();

            if (session != null)
                session.ApplicationClient = this;

            return session;
        }
    }
}


Here is an example of the client:
=========================

using System;

using RemotingServer;

namespace RemotingClient
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                ApplicationClient client = new ApplicationClient();
                client.Login("monoserver");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
            }

            Console.WriteLine("Press key to exit the application ...");
            Console.ReadLine();
        }
    }
}




And here is the exception stacktrace that occurs when assigning the
ApplicationClient instance to the server object.

if (session != null)
  session.ApplicationClient = this;



stacktrace:
=========
System.ArgumentException was unhandled
  Message="Object type System.Int64 cannot be converted to target type:
System.Int32\r\nParametername: val"
  Source="mscorlib"
  ParamName="val"
  StackTrace:
    Server stack trace:
      at System.Reflection.MonoField.SetValue (System.Object obj, System.Object
val, BindingFlags invokeAttr, System.Reflection.Binder binder,
System.Globalization.CultureInfo culture) [0x00000]
      at System.Reflection.FieldInfo.SetValue (System.Object obj, System.Object
value) [0x00000]
      at
System.Runtime.Serialization.Formatters.Binary.ObjectReader.SetObjectValue
(System.Object parentObject, System.String fieldName,
System.Reflection.MemberInfo memberInfo,
System.Runtime.Serialization.SerializationInfo info, System.Object value,
System.Type valueType, System.Int32[] indices) [0x00000]
      at System.Runtime.Serialization.Formatters.Binary.ObjectReader.ReadValue
(System.IO.BinaryReader reader, System.Object parentObject, Int64
parentObjectId, System.Runtime.Serialization.SerializationInfo info,
System.Type valueType, System.String fieldName, System.Reflection.MemberInfo
memberInfo, System.Int32[] indices) [0x00000]
      at
System.Runtime.Serialization.Formatters.Binary.ObjectReader.ReadObjectContent
(System.IO.BinaryReader reader,
System.Runtime.Serialization.Formatters.Binary.TypeMetadata metadata, Int64
objectId, System.Object& objectInstance,
System.Runtime.Serialization.SerializationInfo& info) [0x00000]
      at
System.Runtime.Serialization.Formatters.Binary.ObjectReader.ReadObjectInstance
(System.IO.BinaryReader reader, Boolean isRuntimeObject, Boolean hasTypeInfo,
System.Int64& objectId, System.Object& value,
System.Runtime.Serialization.SerializationInfo& info) [0x00000]
      at System.Runtime.Serialization.Formatters.Binary.ObjectReader.ReadObject
(BinaryElement element, System.IO.BinaryReader reader, System.Int64& objectId,
System.Object& value, System.Runtime.Serialization.SerializationInfo& info)
[0x00000]
      at
System.Runtime.Serialization.Formatters.Binary.ObjectReader.ReadNextObject
(System.IO.BinaryReader reader) [0x00000]
      at
System.Runtime.Serialization.Formatters.Binary.ObjectReader.ReadObjectGraph
(System.IO.BinaryReader reader, Boolean readHeaders, System.Object& result,
System.Runtime.Remoting.Messaging.Header[]& headers) [0x00000]
      at
System.Runtime.Serialization.Formatters.Binary.MessageFormatter.ReadMethodCall
(System.IO.BinaryReader reader, Boolean hasHeaders,
System.Runtime.Remoting.Messaging.HeaderHandler headerHandler,
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter formatter)
[0x00000]
      at
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.NoCheckDeserialize
(System.IO.Stream serializationStream,
System.Runtime.Remoting.Messaging.HeaderHandler handler) [0x00000]
      at
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize
(System.IO.Stream serializationStream,
System.Runtime.Remoting.Messaging.HeaderHandler handler) [0x00000]
      at
System.Runtime.Remoting.Channels.BinaryServerFormatterSink.ProcessMessage
(IServerChannelSinkStack sinkStack, IMessage requestMsg, ITransportHeaders
requestHeaders, System.IO.Stream requestStream, IMessage& responseMsg,
ITransportHeaders& responseHeaders, System.IO.Stream& responseStream) [0x00000]
    Exception rethrown at [0]:
       bei
System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg,
IMessage retMsg)
       bei System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&
msgData, Int32 type)
       bei RemotingServer.SessionObject.set_ApplicationClient(ApplicationClient
value)
       bei RemotingServer.ApplicationClient.Login(String hostname)
       bei RemotingClient.Program.Main(String[] args) in
Y:\Projekte\RemotingClient\RemotingClient\Program.cs:Zeile 12.
       bei System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
       bei Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       bei System.Threading.ExecutionContext.Run(ExecutionContext
executionContext, ContextCallback callback, Object state)
       bei System.Threading.ThreadHelper.ThreadStart()
  InnerException:

-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.


More information about the mono-bugs mailing list