It looks to me that the exception is thrown from Server code
which as message suggest cannot find <metadata Assembly>.

Did you name your real assembly the same way you named meta_assembly?
Do those assembly have strong name?

Anyway the reason the code is failing has nothing to do with enums,
rather when the call is serialized the module name of the assembly
containing definition of enum is serialized as well, and on the
server side during deserialization cannot be found.

-----Original Message-----
From: Matthew Merrill [mailto:[EMAIL PROTECTED]]
Sent: Thursday, February 06, 2003 11:46 AM
To: [EMAIL PROTECTED]
Subject: [ADVANCED-DOTNET] Remoting fails with Enumeration fields


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

This message is for the named person's use only. It may contain sensitive and private 
proprietary or legally privileged information. No confidentiality or privilege is 
waived or lost by any mistransmission. If you are not the intended recipient, please 
immediately delete it and all copies of it from your system, destroy any hard copies 
of it and notify the sender. You must not, directly or indirectly, use, disclose, 
distribute, print, or copy any part of this message if you are not the intended 
recipient. CREDIT SUISSE GROUP and each legal entity in the CREDIT SUISSE FIRST BOSTON 
or CREDIT SUISSE ASSET MANAGEMENT business units of CREDIT SUISSE FIRST BOSTON reserve 
the right to monitor all e-mail communications through its networks. Any views 
expressed in this message are those of the individual sender, except where the message 
states otherwise and the sender is authorized to state them to be the views of any 
such entity.
Unless otherwise stated, any pricing information given in this message is indicative  
only, is subject to change and does not constitute an offer to deal at any price 
quoted. Any reference to the terms of executed transactions should be treated as  
preliminary only and subject to our formal written confirmation.

Reply via email to