A method call to a remote object that contains an enumeration field fails.
When I execute a method containing an enumeration, I receive the following
exception message:

   "An unhandled exception of type 'System.IO.FileNotFoundException' occurred in
   mscorlib.dll
   Additional information: File or assembly name <metaData Assembly>, or one of
   its dependencies, was not found."

where <metaData Assembly> is my metadata only assembly containing a stubbed-out
version of my remote object.

Here is the code for a simple remote object that illustrates the problem:

RemoteTest object (RemoteTest.cs)
----------------------------------------------
using System;

namespace Server
{
   public enum DayOfWeek : int
   {
      Sunday = 0,
      Monday = 1,
      Tuesday = 2,
      Wednesday = 3,
      Thursday = 4,
      Friday = 5,
      Saturday = 6
   }

   public class RemoteTest : MarshalByRefObject
   {
      public RemoteTest()
      {}

      public string doSomething()
      {
         Console.WriteLine("doSomething() called");
         return "someValue";
      }

      public string doSomething(DayOfWeek weekday)
      {
         Console.WriteLine("doSomething(DayOfWeek) called");
         return Enum.GetName(typeof(DayOfWeek), weekday);
      }
   }
}

This class is hosted in a console application (RemoteServerConsole)

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

namespace Server
{
   class RemoteServer
   {
      /// <summary>
      /// The main entry point for the application.
      /// </summary>
      [STAThread]
      static void Main(string[] args)
      {
         Console.WriteLine("Server.Main() started");

         // Register Channel
         TcpChannel chnl = new TcpChannel(1234);
         ChannelServices.RegisterChannel(chnl);

         // Register Remote object
         RemotingConfiguration.RegisterWellKnownServiceType(
            typeof(RemoteTest),
            "RemoteTest.rem",
            WellKnownObjectMode.Singleton);

         // the server will keep running until keypress
         Console.ReadLine();

      }
   }
}

The stubbed out metadata-only assembly for the client:

using System;

namespace Server
{
   public enum DayOfWeek : int
   {
      Sunday = 0,
      Monday = 1,
      Tuesday = 2,
      Wednesday = 3,
      Thursday = 4,
      Friday = 5,
      Saturday = 6
   }

   public class RemoteTest : MarshalByRefObject
   {
      private string message = "\nMethod can not be run locally.\nPlease check
your remoting configuration file.";

      public RemoteTest()
      {}

      public string doSomething()
      { throw new NotSupportedException(message); }

      public string doSomething(DayOfWeek weekday)
      { throw new NotSupportedException(message); }
   }
}

Client Console application:

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

using Server;

namespace Client
{
   class ClientConsole
   {
      /// <summary>The main entry point for the application.</summary>
      [STAThread]
      static void Main(string[] args)
      {
         string filename = "ClientConsole.exe.config";
         RemotingConfiguration.Configure(filename);
         RemoteTest server = new RemoteTest();

         // Execute a method with no enumeration parameters
         Console.WriteLine("calling RemoteTest.doSomething()");
         string result1 = server.doSomething();
         Console.WriteLine("Result: " + result1);

         // Execute method with enumeration parameter.
         Console.WriteLine("calling RemoteTest.doSomething(DayOfWeek)");
         string result2 = server.doSomething(Server.DayOfWeek.Monday);
         Console.WriteLine("Result: " + result2);


      }
   }
}

Client Console configuration file (ClientConsole.exe.config)

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
   <system.runtime.remoting>
      <application>
         <client>
            <wellknown  type="Server.RemoteTest, RemoteTest_Meta"
                        url="tcp://localhost:1234/RemoteTest.rem" />
         </client>
      </application>
   </system.runtime.remoting>
</configuration>


Does anyone know of a solution or workaround for this problem?

Sincerely,
Matthew Merrill
CCH Incorporated

===================================
This list is hosted by DevelopMentor�  http://www.develop.com
You may be interested in this chat on Microsoft Windows Embedded platforms
6 Feb 2003, 9:30am PST Chat Room:
http://communities2.microsoft.com/home/chatroom.aspx?siteid=34000070

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to