internal WellKnownClientTypeEntry[] GetRegisteredWellKnownClientTypes()
            {
                int num = 0;

                foreach (DictionaryEntry entry in this._remoteTypeInfo)
                {
                    if (entry.Value is WellKnownClientTypeEntry)
                    {
                        num++;
                    }
                }
                WellKnownClientTypeEntry[] entryArray = new WellKnownClientTypeEntry[num];
                int num2 = 0;

                foreach (DictionaryEntry entry3 in this._remoteTypeInfo)
                {
                    WellKnownClientTypeEntry entry4 = entry3.Value as WellKnownClientTypeEntry;
                    if (entry4 != null)
                    {
                        WellKnownClientTypeEntry entry5 = new WellKnownClientTypeEntry(entry4.TypeName, entry4.AssemblyName, entry4.ObjectUrl);
                        System.Runtime.Remoting.RemoteAppEntry remoteAppEntry = entry4.GetRemoteAppEntry();
                        if (remoteAppEntry != null)
                        {
                            entry5.ApplicationUrl = remoteAppEntry.GetAppURI();
                        }
                        entryArray[num2++] = entry5;
                    }
                }
                return(entryArray);
            }
        public static void LaunchInExistingInstance(string[] args)
        {
            IpcChannel channel = new IpcChannel();
            ChannelServices.RegisterChannel(channel, false);
            string url = String.Format("ipc://{0}/{1}", ChannelName, SingleInstanceServiceName);

            // Register as client for remote object.
            WellKnownClientTypeEntry remoteType = new WellKnownClientTypeEntry(typeof(SingleInstanceHelper), url);
            RemotingConfiguration.RegisterWellKnownClientType(remoteType);

            // Create a message sink.
            string objectUri;
            IMessageSink messageSink = channel.CreateMessageSink(url, null, out objectUri);

            /*
            Console.WriteLine("The URI of the message sink is {0}.", objectUri);
            if (messageSink != null)
            {
                Console.WriteLine("The type of the message sink is {0}.", messageSink.GetType().ToString());
            }
            */

            SingleInstanceHelper helper = new SingleInstanceHelper();
            helper.Run(args);
        }
 internal void StoreRemoteAppEntries(RemotingXmlConfigFileData configData)
 {
     char[] trimChars = new char[] { '/' };
     foreach (RemotingXmlConfigFileData.RemoteAppEntry entry in configData.RemoteAppEntries)
     {
         string appUri = entry.AppUri;
         if ((appUri != null) && !appUri.EndsWith("/", StringComparison.Ordinal))
         {
             appUri = appUri.TrimEnd(trimChars);
         }
         foreach (RemotingXmlConfigFileData.TypeEntry entry2 in entry.ActivatedObjects)
         {
             ActivatedClientTypeEntry entry3 = new ActivatedClientTypeEntry(entry2.TypeName, entry2.AssemblyName, appUri)
             {
                 ContextAttributes = CreateContextAttributesFromConfigEntries(entry2.ContextAttributes)
             };
             RemotingConfiguration.RegisterActivatedClientType(entry3);
         }
         foreach (RemotingXmlConfigFileData.ClientWellKnownEntry entry4 in entry.WellKnownObjects)
         {
             WellKnownClientTypeEntry entry5 = new WellKnownClientTypeEntry(entry4.TypeName, entry4.AssemblyName, entry4.Url)
             {
                 ApplicationUrl = appUri
             };
             RemotingConfiguration.RegisterWellKnownClientType(entry5);
         }
     }
 }
Example #4
0
    protected static bool RegisterChannnel(int IP)
    {
        // リモート用として、クライアントチャンネルを登録。登録系は同じプロセス内で複数回やるとエラーが出るので、
        try
        {
            System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(ch[IP], false);

            // リモート呼び出しのため、(サーバーにある)オブジェクト取得。
            // Register as client for remote object.
            System.Runtime.Remoting.WellKnownClientTypeEntry remoteType = new System.Runtime.Remoting.WellKnownClientTypeEntry(typeof(HmNodeRemoteObject), "ipc://localhost:" + IP + "/" + HmNodeRemoteObject.Name + IP + ".rem");

            // クライアントタイプとして登録
            System.Runtime.Remoting.RemotingConfiguration.RegisterWellKnownClientType(remoteType);

            // 通知先(Message Sink)のインスタンス生成
            string objectUri;
            System.Runtime.Remoting.Messaging.IMessageSink messageSink = (ch[IP]).CreateMessageSink("ipc://localhost:" + IP + "/" + HmNodeRemoteObject.Name + IP + ".rem", null, out objectUri);
            Console.WriteLine("通知先のURIは {0}.", objectUri);
            if (messageSink != null)
            {
                Console.WriteLine("通知先のクラス型は {0}.", messageSink.GetType().ToString());
            }
        }
        catch (Exception e)
        {
            System.Diagnostics.Debug.WriteLine(e.GetType().ToString());
            System.Diagnostics.Debug.WriteLine(e.Message);

            return(false);
        }

        return(true);
    }
            internal void AddWellKnownClientType(WellKnownClientTypeEntry entry)
            {
                if (this.CheckForRedirectedClientType(entry.TypeName, entry.AssemblyName))
                {
                    throw new RemotingException(string.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("Remoting_Config_TypeAlreadyRedirected"), new object[] { entry.TypeName, entry.AssemblyName }));
                }
                if (this.CheckForServiceEntryWithType(entry.TypeName, entry.AssemblyName))
                {
                    throw new RemotingException(string.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("Remoting_Config_CantRedirectActivationOfWellKnownService"), new object[] { entry.TypeName, entry.AssemblyName }));
                }
                string applicationUrl = entry.ApplicationUrl;

                System.Runtime.Remoting.RemoteAppEntry entry2 = null;
                if (applicationUrl != null)
                {
                    entry2 = (System.Runtime.Remoting.RemoteAppEntry) this._remoteAppInfo[applicationUrl];
                    if (entry2 == null)
                    {
                        entry2 = new System.Runtime.Remoting.RemoteAppEntry(applicationUrl, applicationUrl);
                        this._remoteAppInfo.Add(applicationUrl, entry2);
                    }
                }
                if (entry2 != null)
                {
                    entry.CacheRemoteAppEntry(entry2);
                }
                string key = this.EncodeTypeAndAssemblyNames(entry.TypeName, entry.AssemblyName);

                this._remoteTypeInfo.Add(key, entry);
            }
        public static void RegisterWellKnownClientType(WellKnownClientTypeEntry entry)
        {
            RemotingConfigHandler.RegisterWellKnownClientType(entry);

            // all registrations for wellknown client types will come through here
            RemotingServices.InternalSetRemoteActivationConfigured();
        } // RegisterWellKnownClientType
Example #7
0
 public static void TransmitMessage(string s)
 {
     IpcChannel channel = new IpcChannel();
     ChannelServices.RegisterChannel(channel, false);
     WellKnownClientTypeEntry remoteType = new WellKnownClientTypeEntry(typeof(MessagePasser), "ipc://localhost:9090/MessagePasser.rem");
     RemotingConfiguration.RegisterWellKnownClientType(remoteType);
     MessagePasser passer = new MessagePasser();
     passer.SendMessage(s);
 }
Example #8
0
 public RemoteObject GetService()
 {
     var remoteType =
     new WellKnownClientTypeEntry(
         typeof(RemoteObject),
         _serverUrl + RemoteObject.ObjURL);
     RemotingConfiguration.RegisterWellKnownClientType(remoteType);
     return new RemoteObject();
 }
Example #9
0
 public static WellKnownClientTypeEntry[] GetRegisteredWellKnownClientTypes()
 {
     lock (channelTemplates)
     {
         WellKnownClientTypeEntry[] entries = new WellKnownClientTypeEntry[wellKnownClientEntries.Count];
         wellKnownClientEntries.Values.CopyTo(entries, 0);
         return(entries);
     }
 }
        internal static WellKnownClientTypeEntry IsWellKnownClientType(RuntimeType svrType)
        {
            string simpleAssemblyName      = InternalRemotingServices.GetReflectionCachedData(svrType).SimpleAssemblyName;
            WellKnownClientTypeEntry entry = Info.QueryConnect(svrType.FullName, simpleAssemblyName);

            if (entry == null)
            {
                entry = Info.QueryConnect(svrType.Name, simpleAssemblyName);
            }
            return(entry);
        }
            internal WellKnownClientTypeEntry QueryConnect(string typeName, string assemblyName)
            {
                string str = this.EncodeTypeAndAssemblyNames(typeName, assemblyName);
                WellKnownClientTypeEntry entry = this._remoteTypeInfo[str] as WellKnownClientTypeEntry;

                if (entry == null)
                {
                    return(null);
                }
                return(entry);
            }
Example #12
0
        /// <summary>Retrieves an array of object types registered on the client end as well-known types.</summary>
        /// <returns>An array of object types registered on the client end as well-known types.</returns>
        /// <exception cref="T:System.Security.SecurityException">At least one of the callers higher in the callstack does not have permission to configure remoting types and channels. </exception>
        /// <PermissionSet>
        ///   <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="RemotingConfiguration" />
        /// </PermissionSet>
        public static WellKnownClientTypeEntry[] GetRegisteredWellKnownClientTypes()
        {
            Hashtable obj = RemotingConfiguration.channelTemplates;

            WellKnownClientTypeEntry[] result;
            lock (obj)
            {
                WellKnownClientTypeEntry[] array = new WellKnownClientTypeEntry[RemotingConfiguration.wellKnownClientEntries.Count];
                RemotingConfiguration.wellKnownClientEntries.Values.CopyTo(array, 0);
                result = array;
            }
            return(result);
        }
Example #13
0
        public static void RegisterWellKnownClientType(WellKnownClientTypeEntry entry)
        {
            lock (channelTemplates)
            {
                if (wellKnownClientEntries.ContainsKey(entry.ObjectType) || activatedClientEntries.ContainsKey(entry.ObjectType))
                {
                    throw new RemotingException("Attempt to redirect activation of type '" + entry.ObjectType.FullName + "' which is already redirected.");
                }

                wellKnownClientEntries[entry.ObjectType] = entry;
                ActivationServices.EnableProxyActivation(entry.ObjectType, true);
            }
        }
Example #14
0
    [SecurityPermission(SecurityAction.Demand)] //wtf even is this
    public static void Main(string[] args)
    {
        // Krijo channel
        IpcChannel channel = new IpcChannel();

        // Regjistro channel, percakto sigurine
        System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(channel, false);

        // Regjistro se qka do dergohet, dhe ku
        System.Runtime.Remoting.WellKnownClientTypeEntry remoteType =
            new System.Runtime.Remoting.WellKnownClientTypeEntry(
                typeof(RemoteObject),
                "ipc://localhost:9090/RemoteObject.rem");
        System.Runtime.Remoting.RemotingConfiguration.
        RegisterWellKnownClientType(remoteType);
        // Krijo nje pool te mesazheve
        string objectUri;

        System.Runtime.Remoting.Messaging.IMessageSink messageSink =
            channel.CreateMessageSink(
                "ipc://localhost:9090/RemoteObject.rem", null,
                out objectUri);
        Console.WriteLine("URI e pool te mesazheve eshte {0}.",
                          objectUri);
        if (messageSink != null)
        {
            Console.WriteLine("Lloji i pool te mesazheve eshte {0}.",
                              messageSink.GetType().ToString());
        }

        // Krijo instanc te RemoteObject
        RemoteObject service = new RemoteObject();

        // Thirr metoden e RemoteObject
again:
        Console.WriteLine("Klienti po therret remote object.");
        Console.WriteLine("Remote objecti eshte thirrur " + service.GetCount() + " here.");
        // Mundesi e thjeshte per te perseritur thirrjen
        Console.Write("Deshironi t'e perseritni? (1=po, 0=jo): ");
        int repeat = 1;

        try{ repeat = Int32.Parse(Console.ReadLine()); }
        catch { repeat = 1; }
        if (repeat == 1)
        {
            goto again;
        }
    }
Example #15
0
 public static void GetService(string server, int port, Type type)
 {
     try
     {
         var url = "http://" + server + ":" + port + "/" + type.Name + ".rem";
         TraceOps.Out("Try to get service : " + url);
         var remoteType = new WellKnownClientTypeEntry(type, url);
         remoteType.ApplicationUrl = url;
         TraceOps.Out(remoteType.ObjectUrl);
         RemotingConfiguration.RegisterWellKnownClientType(remoteType);
     }
     catch (Exception exception)
     {
         TraceOps.Out(exception.ToString());
     }
 }
Example #16
0
 // Register a well known client type.
 public static void RegisterWellKnownClientType
     (WellKnownClientTypeEntry entry)
 {
     if (entry == null)
     {
         throw new ArgumentNullException("entry");
     }
     lock (typeof(RemotingConfiguration))
     {
         EnsureLoaded();
         if (registeredClientTypes == null)
         {
             registeredClientTypes = new Hashtable();
         }
         registeredClientTypes[entry.ObjectType] = entry;
     }
 }
Example #17
0
    public static void Main(string[] args)
    {
        //<snippet21>
        // Create the channel.
        IpcChannel channel = new IpcChannel();

        //</snippet21>

        // Register the channel.
        System.Runtime.Remoting.Channels.ChannelServices.
        RegisterChannel(channel);

        // Register as client for remote object.
        System.Runtime.Remoting.WellKnownClientTypeEntry remoteType =
            new System.Runtime.Remoting.WellKnownClientTypeEntry(
                typeof(RemoteObject),
                "ipc://localhost:9090/RemoteObject.rem");
        System.Runtime.Remoting.RemotingConfiguration.
        RegisterWellKnownClientType(remoteType);

        //<snippet22>
        // Create a message sink.
        string objectUri;

        System.Runtime.Remoting.Messaging.IMessageSink messageSink =
            channel.CreateMessageSink(
                "ipc://localhost:9090/RemoteObject.rem", null,
                out objectUri);
        Console.WriteLine("The URI of the message sink is {0}.",
                          objectUri);
        if (messageSink != null)
        {
            Console.WriteLine("The type of the message sink is {0}.",
                              messageSink.GetType().ToString());
        }
        //</snippet22>

        // Create an instance of the remote object.
        RemoteObject service = new RemoteObject();

        // Invoke a method on the remote object.
        Console.WriteLine("The client is invoking the remote object.");
        Console.WriteLine("The remote object has been called {0} times.",
                          service.GetCount());
    }
Example #18
0
    public static void Main(string[] args)
    {
        // Create the client channel.
        IpcClientChannel clientChannel = null;

        if (false)
        {
        }
        else if (args[0] == "1")
        {
            clientChannel = Ctor1();
        }
        else if (args[0] == "2")
        {
            clientChannel = Ctor2();
        }
        else
        {
            throw new ApplicationException("Invalid argument.");
        }

        // Register the channel.
        System.Runtime.Remoting.Channels.ChannelServices.
        RegisterChannel(clientChannel);

        // Register as client for remote object.
        System.Runtime.Remoting.WellKnownClientTypeEntry remoteType =
            new System.Runtime.Remoting.WellKnownClientTypeEntry(
                typeof(RemoteObject),
                "ipc://localhost:9090/RemoteObject.rem");
        System.Runtime.Remoting.RemotingConfiguration.
        RegisterWellKnownClientType(remoteType);

        // Create an instance of the remote object.
        RemoteObject service = new RemoteObject();

        // Invoke a method on the remote object.
        Console.WriteLine("The client is invoking the remote object.");
        Console.WriteLine("The remote object has been called {0} times.",
                          service.GetCount());
    }
Example #19
0
 internal static object CreateClientProxy(WellKnownClientTypeEntry entry)
 {
     return(Connect(entry.ObjectType, entry.ObjectUrl, null));
 }
Example #20
0
            } // GetRegisteredActivatedClientTypes
            

            internal WellKnownClientTypeEntry[] GetRegisteredWellKnownClientTypes()
            {
                // count number of well known client types
                int count = 0;
                foreach (DictionaryEntry dictEntry in _remoteTypeInfo)
                {
                    WellKnownClientTypeEntry entry = dictEntry.Value as WellKnownClientTypeEntry;                
                    if (entry != null)
                        count++;
                }
                            
                WellKnownClientTypeEntry[] entries =
                    new WellKnownClientTypeEntry[count];

                int co = 0;
                foreach (DictionaryEntry dictEntry in _remoteTypeInfo)
                {
                    WellKnownClientTypeEntry entry = dictEntry.Value as WellKnownClientTypeEntry;

                    if (entry != null)
                    {                    
                        WellKnownClientTypeEntry wkcte =
                            new WellKnownClientTypeEntry(entry.TypeName, 
                                entry.AssemblyName, entry.ObjectUrl);

                        // see if there is an associated app
                        RemoteAppEntry remApp = entry.GetRemoteAppEntry();
                        if (remApp != null)
                            wkcte.ApplicationUrl = remApp.GetAppURI();                             

                        entries[co++] = wkcte;
                    }
                    
                }
                   
                return entries;
            } // GetRegisteredWellKnownClientTypes
	// Register a well known client type.
	public static void RegisterWellKnownClientType
				(WellKnownClientTypeEntry entry)
			{
				if(entry == null)
				{
					throw new ArgumentNullException("entry");
				}
				lock(typeof(RemotingConfiguration))
				{
					EnsureLoaded();
					if(registeredClientTypes == null)
					{
						registeredClientTypes = new Hashtable();
					}
					registeredClientTypes[entry.ObjectType] = entry;
				}
			}
        public static void RegisterWellKnownClientType(WellKnownClientTypeEntry entry)
        {
            RemotingConfigHandler.RegisterWellKnownClientType(entry);

            // all registrations for wellknown client types will come through here
            RemotingServices.InternalSetRemoteActivationConfigured();
        } // RegisterWellKnownClientType
Example #23
0
        private bool Register(bool showmessage, String IP, String Port)
        {
            if (IP != "")
            {
                CliUtils.fRemoteIP = IP;
                if (Port == null || Port == "")
                    CliUtils.fRemotePort = 8989;
                else
                    CliUtils.fRemotePort = Convert.ToInt16(Port);
                LoginService loginService = new LoginService(); // Remoting object
            GetLoginService:
                // Try to connect to server, reobtain service from the master server if failed
                try
                {
                    EEPRemoteModule module = Activator.GetObject(typeof(EEPRemoteModule),
                        string.Format("http://{0}:" + CliUtils.fRemotePort + "/InfoRemoteModule.rem", CliUtils.fRemoteIP)) as EEPRemoteModule;
                    // module.ToString(); andy kao modified
                }
                catch
                {
                    loginService.DeRegisterRemoteServer(CliUtils.fRemoteIP, CliUtils.fRemotePort);
                    goto GetLoginService;
                }

                // Register EEPRemoteModule on the server
                WellKnownClientTypeEntry clientEntry = new WellKnownClientTypeEntry(typeof(EEPRemoteModule),
                    string.Format("http://{0}:" + CliUtils.fRemotePort + "/InfoRemoteModule.rem", CliUtils.fRemoteIP));
                RemotingConfiguration.RegisterWellKnownClientType(clientEntry);

                // End Add
                isRegister = true;
            }
            return isRegister;
        }
Example #24
0
		internal static object CreateClientProxy (WellKnownClientTypeEntry entry)
		{
			return Connect (entry.ObjectType, entry.ObjectUrl, null);
		}
Example #25
0
 /// <summary>
 /// Get entry from array based on objectUrl or null if not match. We can not use Linq here because NO examples comes also in .Net 2
 /// </summary>
 /// <param name="entries">entries from RemotingConfiguration</param>
 /// <param name="objectUrl">target url</param>
 /// <returns>entry or null</returns>
 private static WellKnownClientTypeEntry GetEntry(WellKnownClientTypeEntry[] entries, string objectUrl)
 {
     foreach (WellKnownClientTypeEntry item in entries)
     {
         if (objectUrl.Equals(item.ObjectUrl, StringComparison.InvariantCultureIgnoreCase))
             return item;
     }
     return null;
 }
Example #26
0
        public static void RegisterWellKnownClientType(Type type, string objectUrl)
        {
            WellKnownClientTypeEntry entry = new WellKnownClientTypeEntry(type, objectUrl);

            RemotingConfiguration.RegisterWellKnownClientType(entry);
        }
 public static void RegisterWellKnownClientType(WellKnownClientTypeEntry entry)
 {
   Contract.Requires(entry != null);
   Contract.Requires(entry.AssemblyName != null);
 }
Example #28
0
        static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            CliUtils.fClientLang = GetClientLanguage();
            String s;
            s = Application.StartupPath + "\\";
            RemotingConfiguration.Configure(s + "EEPNetRunStep.exe.config", true);

            RegistryKey rk = Registry.LocalMachine.OpenSubKey("SOFTWARE\\infolight\\eep.net");
            String sPath = (String)rk.GetValue("Server Path");
            rk.Close();
            if (sPath.Length > 0 && sPath[sPath.Length - 1] != '\\') sPath = sPath + "\\";
            string name = "EEPNetRunStep";

            try
            {
                XmlDocument DBXML = new XmlDocument();
                FileStream aFileStream;
                if (!File.Exists(sPath + "Path.xml"))
                {
                    try
                    {
                        aFileStream = new FileStream(sPath + "Path.xml", FileMode.Create, FileAccess.ReadWrite, FileShare.None);
                        try
                        {
                            XmlTextWriter w = new XmlTextWriter(aFileStream, new System.Text.ASCIIEncoding());
                            w.Formatting = Formatting.Indented;
                            w.WriteStartElement("InfolightAutoRunMessage");
                            w.WriteEndElement();
                            w.Close();
                        }
                        finally
                        {
                            aFileStream.Close();
                        }
                    }
                    catch (Exception e)
                    {
                        string str = e.Message;
                    }
                }

                try
                {
                    aFileStream = new FileStream(sPath + "Path.xml", FileMode.Open, FileAccess.ReadWrite, FileShare.None);
                    try
                    {
                        DBXML.Load(aFileStream);
                        XmlNode aNode = null;

                        for (int j = DBXML.DocumentElement.ChildNodes.Count - 1; j >= 0; j--)
                        {
                            if (DBXML.DocumentElement.ChildNodes[j].Attributes["Name"].InnerText.Trim().ToUpper().Equals(name.ToUpper()))
                            {
                                aNode = DBXML.DocumentElement.ChildNodes[j];
                                break;
                            }
                        }

                        if (aNode == null)
                        {

                            XmlElement elem = DBXML.CreateElement("String");

                            XmlAttribute attr = DBXML.CreateAttribute("Name");
                            attr.Value = name;
                            elem.Attributes.Append(attr);

                            attr = DBXML.CreateAttribute("Path");
                            attr.Value = Application.StartupPath;
                            elem.Attributes.Append(attr);

                            DBXML.DocumentElement.AppendChild(elem);
                        }
                        else
                        {
                            aNode.Attributes["Path"].InnerText = Application.StartupPath;
                        }
                    }
                    finally
                    {
                        aFileStream.Close();
                    }
                    DBXML.Save(sPath + "Path.xml");
                }
                catch (Exception e)
                {
                    string str = e.Message;
                }
            }
            finally { }

            LoginService loginService = new LoginService(); // Remoting object

            BeginObtainService:
            // Obtain service from the master server
            string serverIP = "";

            try
            {
                serverIP = loginService.GetServerIP();

            }
            catch (Exception err)
            {
                if ((string.Compare(err.Message.ToLower(), "unable to connect to the remote server") == 0) &&
                    CliUtils.PassByEEPListener())
                {
                    try
                    {
                        CliUtils.EEPListenerService.StartupEEPNetServer();
                    }
                    catch (Exception E)
                    {
                        MessageBox.Show(E.Message);
                        //this.Close();
                        return;
                    }
                    goto BeginObtainService;
                }
                else
                {
                    MessageBox.Show(err.Message);
                    //this.Close();
                    return;
                }
            }

            if (serverIP == null || serverIP.Trim() == "")
            {
                MessageBox.Show("Can not login due to busy service");
                //this.Close();
                return;
            }

            // Try to connect to server, reobtain service from the master server if failed
            try
            {
                EEPRemoteModule module = Activator.GetObject(typeof(EEPRemoteModule),
                    string.Format("http://{0}:8989/InfoRemoteModule.rem", serverIP)) as EEPRemoteModule;
                module.ToString();
            }
            catch
            {
                loginService.DeRegisterRemoteServer(serverIP);
                goto BeginObtainService;
            }

            // Register EEPRemoteModule on the server
            WellKnownClientTypeEntry clientEntry = new WellKnownClientTypeEntry(typeof(EEPRemoteModule),
                string.Format("http://{0}:8989/InfoRemoteModule.rem", serverIP));
            RemotingConfiguration.RegisterWellKnownClientType(clientEntry);

            // End Add
            if (args.Length > 0)
            {
                string[] temp = args[0].Split('!');
                string userMessage = temp[0];
                string[] packageMessage = temp[1].Split(',');
                string interval = temp[2];
                string log = temp[3];
                Mutex m = new Mutex(false, userMessage);
                Application.Run(new frmEEPNetRunStep(userMessage, packageMessage, interval, log));
            }
            else
                Application.Run(new frmEEPNetRunStep());
        }
 internal WellKnownClientTypeEntry[] GetRegisteredWellKnownClientTypes()
 {
     int num = 0;
     foreach (DictionaryEntry entry in this._remoteTypeInfo)
     {
         if (entry.Value is WellKnownClientTypeEntry)
         {
             num++;
         }
     }
     WellKnownClientTypeEntry[] entryArray = new WellKnownClientTypeEntry[num];
     int num2 = 0;
     foreach (DictionaryEntry entry3 in this._remoteTypeInfo)
     {
         WellKnownClientTypeEntry entry4 = entry3.Value as WellKnownClientTypeEntry;
         if (entry4 != null)
         {
             WellKnownClientTypeEntry entry5 = new WellKnownClientTypeEntry(entry4.TypeName, entry4.AssemblyName, entry4.ObjectUrl);
             System.Runtime.Remoting.RemoteAppEntry remoteAppEntry = entry4.GetRemoteAppEntry();
             if (remoteAppEntry != null)
             {
                 entry5.ApplicationUrl = remoteAppEntry.GetAppURI();
             }
             entryArray[num2++] = entry5;
         }
     }
     return entryArray;
 }
 internal void AddWellKnownClientType(WellKnownClientTypeEntry entry)
 {
     if (this.CheckForRedirectedClientType(entry.TypeName, entry.AssemblyName))
     {
         throw new RemotingException(string.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("Remoting_Config_TypeAlreadyRedirected"), new object[] { entry.TypeName, entry.AssemblyName }));
     }
     if (this.CheckForServiceEntryWithType(entry.TypeName, entry.AssemblyName))
     {
         throw new RemotingException(string.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("Remoting_Config_CantRedirectActivationOfWellKnownService"), new object[] { entry.TypeName, entry.AssemblyName }));
     }
     string applicationUrl = entry.ApplicationUrl;
     System.Runtime.Remoting.RemoteAppEntry entry2 = null;
     if (applicationUrl != null)
     {
         entry2 = (System.Runtime.Remoting.RemoteAppEntry) this._remoteAppInfo[applicationUrl];
         if (entry2 == null)
         {
             entry2 = new System.Runtime.Remoting.RemoteAppEntry(applicationUrl, applicationUrl);
             this._remoteAppInfo.Add(applicationUrl, entry2);
         }
     }
     if (entry2 != null)
     {
         entry.CacheRemoteAppEntry(entry2);
     }
     string key = this.EncodeTypeAndAssemblyNames(entry.TypeName, entry.AssemblyName);
     this._remoteTypeInfo.Add(key, entry);
 }
 internal void StoreRemoteAppEntries(RemotingXmlConfigFileData configData)
 {
     char[] trimChars = new char[] { '/' };
     foreach (RemotingXmlConfigFileData.RemoteAppEntry entry in configData.RemoteAppEntries)
     {
         string appUri = entry.AppUri;
         if ((appUri != null) && !appUri.EndsWith("/", StringComparison.Ordinal))
         {
             appUri = appUri.TrimEnd(trimChars);
         }
         foreach (RemotingXmlConfigFileData.TypeEntry entry2 in entry.ActivatedObjects)
         {
             ActivatedClientTypeEntry entry3 = new ActivatedClientTypeEntry(entry2.TypeName, entry2.AssemblyName, appUri) {
                 ContextAttributes = CreateContextAttributesFromConfigEntries(entry2.ContextAttributes)
             };
             RemotingConfiguration.RegisterActivatedClientType(entry3);
         }
         foreach (RemotingXmlConfigFileData.ClientWellKnownEntry entry4 in entry.WellKnownObjects)
         {
             WellKnownClientTypeEntry entry5 = new WellKnownClientTypeEntry(entry4.TypeName, entry4.AssemblyName, entry4.Url) {
                 ApplicationUrl = appUri
             };
             RemotingConfiguration.RegisterWellKnownClientType(entry5);
         }
     }
 }
Example #32
0
 // helper for Configuration::RegisterWellKnownClientType
 internal static void RegisterWellKnownClientType(WellKnownClientTypeEntry entry)
 {
     Info.AddWellKnownClientType(entry);
 } 
 public static void RegisterWellKnownClientType(WellKnownClientTypeEntry entry)
 {
     throw new NotImplementedException();
 }
Example #34
0
        public bool Connect()
        {
            try
            {
                WellKnownClientTypeEntry CoRemote =
                new WellKnownClientTypeEntry(typeof(RpcConnector), "tcp://" + _Ip + ":" + _Port + "/" + typeof(RpcConnector).Name + _Key);

                if (_Channel == null)
                {
                    _Channel = new TcpChannel();
                    ChannelServices.RegisterChannel(_Channel, false);
                    RemotingConfiguration.RegisterWellKnownClientType(CoRemote);
                }

                Log.Info("Connect", "Registering connector : " + CoRemote.ObjectUrl);

                Connector = (RpcConnector)Activator.GetObject(CoRemote.ObjectType, CoRemote.ObjectUrl);
                _Id = Connector.Connect(_Name);

                Log.Success("RpcClient", "Connected to : " + _Ip + ":" + _Port);
                Load();
            }
            catch (Exception e)
            {
                Log.Error("RcpClient", "Can not connect to : " + _Ip + ":" + _Port);
                Log.Error("RpcClient", "Erreur = " + e.ToString());
                try
                {
                    ChannelServices.UnregisterChannel(_Channel);
                }
                catch (Exception) { }

                _Channel = null;
                return false;
            }

            try
            {
                _Ping = new Timer();
                _Ping.Interval = 1000;
                _Ping.Elapsed += Ping;
                _Ping.Start();
            }
            catch (Exception e)
            {
                Log.Error("RpcClient", "Erreur :" + e.ToString());
            }

            return true;
        }
 public static void RegisterWellKnownClientType(Type type, string objectUrl)
 {
     WellKnownClientTypeEntry entry = new WellKnownClientTypeEntry(type, objectUrl);
     RegisterWellKnownClientType(entry);
 }
Example #36
0
 public static void RegisterWellKnownClientType(WellKnownClientTypeEntry entry)
 {
     RemotingConfigHandler.RegisterWellKnownClientType(entry);
     RemotingServices.InternalSetRemoteActivationConfigured();
 }
Example #37
0
		[Category ("NotWorking")] // disabled as it got not working by NUnit upgrade to 2.4.8
		public void MultiClientConnection ()
		{
			int num_clients = 20;
			
			Hashtable options = new Hashtable ();
			options ["timeout"] = 10000; // 10s
			options ["name"] = "MultiClientConnection"; // 10s
			HttpClientChannel clientChannel = new HttpClientChannel (options, null);
			ChannelServices.RegisterChannel (clientChannel);
			try {
			
			WellKnownClientTypeEntry remoteType = new WellKnownClientTypeEntry (
				typeof (RemoteObject), "http://127.0.0.1:9090/RemoteObject.rem");
			RemotingConfiguration.RegisterWellKnownClientType (remoteType);
			
			// start a bunch of clients...
			Thread []clients = new Thread [num_clients];
			retvals = new bool [num_clients];
			
			lock (mutex) {
				for (int i = 0; i < num_clients; i++) {
					clients[i] = new Thread (MultiClientStart);
					clients[i].Start ();
					retvals[i] = false;
				}
			}
			
			// wait for all clients to finish...
			for (int i = 0; i < num_clients; i++)
				clients[i].Join ();
			
			for (int i = 0; i < num_clients; i++)
				Assert.IsTrue (retvals[i], "RemoteObject.Incrememnt() didn't return a value of " + i);

			} finally {
			ChannelServices.UnregisterChannel (clientChannel);
			}
		}
Example #38
0
        private void CheckUser(bool relogin)
        {
            CliUtils.fLoginUser = fFrmLogin.GetUserId();
            CliUtils.fLoginPassword = fFrmLogin.GetPwd();
            CliUtils.fLoginDB = fFrmLogin.GetDB();
            LoginResult result = LoginResult.Success;
            if (CliUtils.fLoginUser.Contains("'"))
            {
                result = LoginResult.UserNotFound;
            }
            else
            {
                EEPRemoteModule module = Activator.GetObject(typeof(EEPRemoteModule)
                       , string.Format("http://{0}:{1}/InfoRemoteModule.rem", CliUtils.fRemoteIP, CliUtils.fRemotePort)) as EEPRemoteModule;
                try
                {
                    module.ToString();
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message);
                    CheckUser();
                    return;
                }

                string sParam = CliUtils.fLoginUser + ':' + CliUtils.fLoginPassword + ':' + CliUtils.fLoginDB;
                if (relogin)
                {
                    sParam += ":1";
                }
                else
                {
                    sParam += ":0";
                }

                object[] myRet = module.CallMethod(new object[] { CliUtils.GetBaseClientInfo() }, "GLModule", "CheckManagerRight", new object[] { CliUtils.fLoginDB, CliUtils.fLoginUser });
                if (myRet[1].ToString() != "0")
                {
                    if (myRet[1].ToString() == "1")
                    {
                        MessageBox.Show("No right to use Manager.");
                    }
                    else
                    {
                        MessageBox.Show("User Not Found.");
                    }
                    if (fFrmLogin.ShowDialog(this) == DialogResult.OK)
                    {
                        CheckUser();
                    }
                    else
                    {
                        this.Close();
                    }
                    return;
                }

                myRet = module.CallMethod(new object[] { CliUtils.GetBaseClientInfo() }, "GLModule", "CheckUser", new object[] { (object)sParam });
                result = (LoginResult)myRet[1];
                switch (result)
                {
                    case LoginResult.UserNotFound:
                        {
                            string message = SysMsg.GetSystemMessage(CliUtils.fClientLang, "EEPWebNetClient", "WinSysMsg", "msg_UserNotFound");
                            MessageBox.Show(this, message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            break;
                        }
                    case LoginResult.PasswordError:
                        {
                            string message = SysMsg.GetSystemMessage(CliUtils.fClientLang, "EEPWebNetClient", "WinSysMsg", "msg_UserOrPasswordError");
                            MessageBox.Show(this, message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            break;
                        }
                    case LoginResult.Disabled:
                        {
                            string message = SysMsg.GetSystemMessage(CliUtils.fClientLang, "EEPWebNetClient", "WinSysMsg", "msg_UserDisabled");
                            MessageBox.Show(this, message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            break;
                        }
                    case LoginResult.UserLogined:
                        {
                            string message = SysMsg.GetSystemMessage(CliUtils.fClientLang, "EEPWebNetClient", "WinSysMsg", "msg_UserIsLogined");
                            MessageBox.Show(this, string.Format(message, CliUtils.fLoginUser), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            break;
                        }
                    case LoginResult.RequestReLogin:
                        {
                            string message = SysMsg.GetSystemMessage(CliUtils.fClientLang, "EEPWebNetClient", "WinSysMsg", "msg_UserReLogined");
                            if (MessageBox.Show(string.Format(message, CliUtils.fLoginUser)
                                , "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                            {
                                CheckUser(true);
                            }
                            else
                            {
                                CliUtils.fLoginUser = string.Empty;
                                this.Close();
                            }
                            return;
                        }
                    default:
                        {
                            WellKnownClientTypeEntry clientEntry = new WellKnownClientTypeEntry(typeof(EEPRemoteModule),
                               string.Format("http://{0}:{1}/InfoRemoteModule.rem", CliUtils.fRemoteIP, CliUtils.fRemotePort));
                            RemotingConfiguration.RegisterWellKnownClientType(clientEntry);
                            CliUtils.fUserName = myRet[2].ToString();
                            CliUtils.fLoginUser = myRet[3].ToString();
                            CliUtils.GetPasswordPolicy();
                            myRet = CliUtils.CallMethod("GLModule", "GetUserGroup", new object[] { CliUtils.fLoginUser });
                            if (myRet != null && (int)myRet[0] == 0)
                            {
                                CliUtils.fGroupID = myRet[1].ToString();
                            }
                            SaveToManagerXML(CliUtils.fLoginUser, CliUtils.fLoginDB, CliUtils.fRemoteIP + ":" + CliUtils.fRemotePort.ToString());

                            object[] DataBaseType = CliUtils.CallMethod("GLModule", "GetDataBaseType", new object[] { CliUtils.fLoginDB, false });
                            if (DataBaseType != null && DataBaseType[0].ToString() == "0")
                            {
                                //0:None   1:Sql Server   2:OleDb   3:Oracle   4:Odbc   5:MySql
                                switch (DataBaseType[1].ToString())
                                {
                                    case "1": CliUtils.fLoginDBType = ClientType.ctMsSql; break;
                                    case "2": CliUtils.fLoginDBType = ClientType.ctOleDB; break;
                                    case "3": CliUtils.fLoginDBType = ClientType.ctOracle; break;
                                    case "4": CliUtils.fLoginDBType = ClientType.ctODBC; break;
                                    case "5": CliUtils.fLoginDBType = ClientType.ctMySql; break;
                                    case "6": CliUtils.fLoginDBType = ClientType.ctInformix; break;
                                }
                            }
                            DisabledSystemMenuItem(!CliUtils.fLoginDBSplit);
                            break;
                        }
                }
            }
            if (result != LoginResult.Success)
            {
                if (fFrmLogin.ShowDialog(this) == DialogResult.OK)
                {
                    CheckUser();
                }
                else
                {
                    CliUtils.fLoginUser = string.Empty;
                    this.Close();
                }
            }
        }
 public static void RegisterWellKnownClientType(WellKnownClientTypeEntry entry)
 {
     RemotingConfigHandler.RegisterWellKnownClientType(entry);
     RemotingServices.InternalSetRemoteActivationConfigured();
 }
Example #40
0
        public static bool Register(ref string showmessage, bool loadbalance)
        {
            bool isWeb = string.Compare(fClientSystem, "Web", true) == 0;
            if (RemotingConfiguration.IsWellKnownClientType(typeof(EEPRemoteModule)) != null)
            {
                EEPRemoteModule module = new EEPRemoteModule();
                try
                {
                    module.ToString();
                    return true;
                }
                catch
                {
                    try
                    {
                        //EEPListenerService.StartupEEPNetServer();
                        LoadServer();
                        module.ToString();
                        return true;
                    }
                    catch
                    {
                        try
                        {
                            showmessage = SysMsg.GetSystemMessage(fClientLang, "EEPWebNetClient", "WinSysMsg", "msg_CanNotFindServer", isWeb);
                        }
                        catch
                        {
                            showmessage = "Unable to connect to the remote server";
                        }
                        return false;
                    }
                }
            }

            if (string.Compare(fRemoteIP, "127.0.0.1") != 0 && string.Compare(fRemoteIP, "localhost", true) != 0)
            {
                LoginService loginService = Activator.GetObject(typeof(LoginService),
                        string.Format("http://{0}:{1}/Srvtools.rem", fRemoteIP, fRemotePort)) as LoginService;
            GetLoginService:
                try
                {
                    object[] rtn = loginService.GetServerIP(loadbalance);
                    string newip = rtn[0].ToString();
                    if (newip == null || newip.Trim() == "")
                    {
                        try
                        {
                            showmessage = SysMsg.GetSystemMessage(fClientLang, "EEPWebNetClient", "WinSysMsg", "msg_BusyService", isWeb);
                        }
                        catch
                        {
                            showmessage = "System Busy, try again later";
                        }
                        return false;
                    }
                    else if (newip == "000")
                    {
                        try
                        {
                            if (fClientSystem == "Web")
                            {
                                showmessage = SysMsg.GetSystemMessage(fClientLang, "Web", "InfoLogin", "ExceedsMax", isWeb);
                            }
                            else
                            {
                                showmessage = SysMsg.GetSystemMessage(fClientLang, "EEPNetClient", "FrmClientMain", "ExceedsMax", isWeb);
                            }
                        }
                        catch
                        {
                            showmessage = "The current number of users exceeds the max number set by the AP server!try again?";
                        }
                        return false;
                    }
                    else if (newip != "001")  //has redirect to another server
                    {
                        fRemoteIP = newip;
                        fRemotePort = (int)rtn[1];
                    }
                }
                catch (WebException E)
                {
                    if (E.Status == WebExceptionStatus.ConnectFailure)
                    {
                        if (fRemoteIP != reserveServerIP)
                        {
                            if (LoadServer())
                            {
                                goto GetLoginService;
                            }
                            else if (reserveServerIP.Length > 0)
                            {
                                fRemoteIP = reserveServerIP;
                                fRemotePort = reserveServerPort;
                                return Register(ref showmessage, loadbalance);
                            }
                        }

                        string message = E.Message;
                        if (E.Message == "Unable to connect to the remote server")
                        {
                            try
                            {
                                message = SysMsg.GetSystemMessage(fClientLang, "EEPWebNetClient", "WinSysMsg", "msg_CanNotFindServer", isWeb);
                            }
                            catch
                            {
                                message = "Unable to connect to the remote server";
                            }
                        }
                        showmessage = message;
                        return false;
                    }
                    else
                    {
                        showmessage = E.Message;
                        return false;
                    }
                }

                try
                {
                    EEPRemoteModule module = Activator.GetObject(typeof(EEPRemoteModule),
                        string.Format("http://{0}:{1}/InfoRemoteModule.rem", fRemoteIP, fRemotePort)) as EEPRemoteModule;
                    module.ToString();
                }
                catch
                {
                    loginService.DeRegisterRemoteServer(fRemoteIP, fRemotePort);
                    goto GetLoginService;
                }
            }
            else// local host do not load banlance
            {
                try
                {
                    EEPRemoteModule module = Activator.GetObject(typeof(EEPRemoteModule),
                        string.Format("http://{0}:{1}/InfoRemoteModule.rem", fRemoteIP, fRemotePort)) as EEPRemoteModule;
                    module.ToString();
                }
                catch (Exception e)
                {
                    try
                    {
                        //EEPListenerService.StartupEEPNetServer();
                        LoadServer();
                        EEPRemoteModule module = Activator.GetObject(typeof(EEPRemoteModule),
                         string.Format("http://{0}:{1}/InfoRemoteModule.rem", fRemoteIP, fRemotePort)) as EEPRemoteModule;
                        module.ToString();
                    }
                    catch
                    {
                        string message = e.Message;
                        try
                        {
                            message = SysMsg.GetSystemMessage(fClientLang, "EEPWebNetClient", "WinSysMsg", "msg_CanNotFindServer", isWeb);
                        }
                        catch
                        {
                            message = "Unable to connect to the remote server";
                        }
                        showmessage = message;
                        return false;
                    }
                }
            }

            // Register EEPRemoteModule on the server
            WellKnownClientTypeEntry clientEntry = new WellKnownClientTypeEntry(typeof(EEPRemoteModule),
                string.Format("http://{0}:{1}/InfoRemoteModule.rem", fRemoteIP, fRemotePort));
            RemotingConfiguration.RegisterWellKnownClientType(clientEntry);
            return true;
        }
Example #41
0
        //解析并注册WellKnown对象
        void ParseWellKnownClientObjectSection(XmlNode root)
        {
            foreach (XmlNode node in root.ChildNodes)
            {
                if (node.NodeType == XmlNodeType.Comment) continue;
                if (node.Name != "add") continue;

                string objectUri = base.GetStringAttribute(node, "objectUri");
                if (string.IsNullOrEmpty(objectUri)) continue;

                string fullTypeName = base.GetStringAttribute(node, "type");
                if (string.IsNullOrEmpty(fullTypeName)) continue;

                string typeName = fullTypeName.Split(',')[0];
                string assemblyName = string.Empty;

                if (fullTypeName.IndexOf(',') != -1)
                {
                    assemblyName = fullTypeName.Split(',')[1];
                }
                else
                {
                    Assembly assembly = ReflectUtil.FindAssemblyFromAppDirectory(typeName);
                    if (assembly != null)
                        assemblyName = assembly.FullName;
                }

                WellKnownClientTypeEntry wce = new WellKnownClientTypeEntry(typeName, assemblyName, objectUri);
                RemotingConfiguration.RegisterWellKnownClientType(wce);
            }
        }
 public static void RegisterWellKnownClientType(Type type, String objectUrl)
 {
     WellKnownClientTypeEntry wke = new WellKnownClientTypeEntry(type, objectUrl);
     RemotingConfiguration.RegisterWellKnownClientType(wke);
 } // RegisterWellKnownClientType
 public static void RegisterWellKnownClientType(WellKnownClientTypeEntry entry)
 {
     Contract.Requires(entry != null);
     Contract.Requires(entry.AssemblyName != null);
 }
Example #44
0
		TcpClientChannel GetClientChannel (string name, string uri)
		{
			TcpClientChannel clientChannel = new TcpClientChannel (name + "Client", null);
			ChannelServices.RegisterChannel (clientChannel);
			
			WellKnownClientTypeEntry remoteType = new WellKnownClientTypeEntry (
				typeof (RemoteObject), uri + "/RemoteObject.rem");
			RemotingConfiguration.RegisterWellKnownClientType (remoteType);
			
			return clientChannel;
		}
		public static WellKnownClientTypeEntry[] GetRegisteredWellKnownClientTypes () 
		{
			lock (channelTemplates)
			{
				WellKnownClientTypeEntry[] entries = new WellKnownClientTypeEntry[wellKnownClientEntries.Count];
				wellKnownClientEntries.Values.CopyTo (entries,0);
				return entries;
			}
		}
Example #46
0
            } // StoreInteropEntries

            internal void StoreRemoteAppEntries(RemotingXmlConfigFileData configData)
            {
                char[] slash = new char[]{'/'};
            
                // add each remote app to the table
                foreach (RemotingXmlConfigFileData.RemoteAppEntry remApp in configData.RemoteAppEntries)
                {
                    // form complete application uri by combining specified uri with app-name
                    //  (make sure appUri ends with slash, and that app name doesn't start,
                    //   with one. then make sure that the combined form has no trailing slashes).
                    String appUri = remApp.AppUri;
                    if ((appUri != null) && !appUri.EndsWith("/", StringComparison.Ordinal))
                        appUri = appUri.TrimEnd(slash);
                        
                    // add each client activated type for this remote app
                    foreach (RemotingXmlConfigFileData.TypeEntry cae in remApp.ActivatedObjects)
                    {
                        ActivatedClientTypeEntry acte = 
                            new ActivatedClientTypeEntry(cae.TypeName, cae.AssemblyName, 
                                                         appUri);
                        acte.ContextAttributes = 
                            CreateContextAttributesFromConfigEntries(cae.ContextAttributes);
                   
                        RemotingConfiguration.RegisterActivatedClientType(acte);
                    }

                    // add each well known object for this remote app
                    foreach (RemotingXmlConfigFileData.ClientWellKnownEntry cwke in remApp.WellKnownObjects)
                    {                    
                        WellKnownClientTypeEntry wke = 
                            new WellKnownClientTypeEntry(cwke.TypeName, cwke.AssemblyName, 
                                                         cwke.Url);
                        wke.ApplicationUrl = appUri;
                        
                        RemotingConfiguration.RegisterWellKnownClientType(wke);
                    }          
                }
            } // StoreRemoteAppEntries            
		public static void RegisterWellKnownClientType (WellKnownClientTypeEntry entry) 
		{
			lock (channelTemplates)
			{
				if (wellKnownClientEntries.ContainsKey (entry.ObjectType) || activatedClientEntries.ContainsKey (entry.ObjectType))
					throw new RemotingException ("Attempt to redirect activation of type '" + entry.ObjectType.FullName + "' which is already redirected.");
	
				wellKnownClientEntries[entry.ObjectType] = entry;
				ActivationServices.EnableProxyActivation (entry.ObjectType, true);
			}
		}
Example #48
0
            } // AddActivatedClientType


            internal void AddWellKnownClientType(WellKnownClientTypeEntry entry)
            {
                if (CheckForRedirectedClientType(entry.TypeName, entry.AssemblyName))
                {
                    throw new RemotingException(
                        String.Format(
                            CultureInfo.CurrentCulture, Environment.GetResourceString(
                                "Remoting_Config_TypeAlreadyRedirected"),
                            entry.TypeName, entry.AssemblyName));
                }    

                if (CheckForServiceEntryWithType(entry.TypeName, entry.AssemblyName))
                {
                    throw new RemotingException(
                        String.Format(
                            CultureInfo.CurrentCulture, Environment.GetResourceString(
                                "Remoting_Config_CantRedirectActivationOfWellKnownService"),
                            entry.TypeName, entry.AssemblyName));
                }
            
            
                String appUrl = entry.ApplicationUrl;

                RemoteAppEntry appEntry = null;
                if (appUrl != null)
                {
                    appEntry = (RemoteAppEntry)_remoteAppInfo[appUrl];
                    if (appEntry == null)
                    {
                        appEntry = new RemoteAppEntry(appUrl, appUrl);
                        _remoteAppInfo.Add(appUrl, appEntry);
                    }
                }
            
                if (appEntry != null)
                    entry.CacheRemoteAppEntry(appEntry);

                String index = EncodeTypeAndAssemblyNames(entry.TypeName, entry.AssemblyName);
                _remoteTypeInfo.Add(index, entry);
            } // AddWellKnownClientType
        public static void RegisterWellKnownClientType(Type type, String objectUrl)
        {
            WellKnownClientTypeEntry wke = new WellKnownClientTypeEntry(type, objectUrl);

            RemotingConfiguration.RegisterWellKnownClientType(wke);
        } // RegisterWellKnownClientType
 internal static void RegisterWellKnownClientType(WellKnownClientTypeEntry entry)
 {
     Info.AddWellKnownClientType(entry);
 }
Example #51
0
        public void Load()
        {
            Log.Info("RpcClient", "Loading");

            foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
            {
                foreach (Type type in assembly.GetTypes())
                {
                    if (!type.IsClass)
                        continue;

                    if (!type.IsSubclassOf(typeof(ARpc)))
                        continue;

                    object[] attrib = type.GetCustomAttributes(typeof(RpcAttributes), true);
                    if (attrib.Length <= 0)
                        continue;

                    RpcAttributes[] packethandlerattribs =
                    (RpcAttributes[])type.GetCustomAttributes(typeof(RpcAttributes), true);

                    if (packethandlerattribs.Length <= 0)
                        continue;

                    foreach (string auth in packethandlerattribs[0].Authorised)
                    {
                        if (auth.StartsWith(_Name))
                        {
                            Log.Debug("RpcClient", "Registering class : " + type.Name);

                            WellKnownClientTypeEntry remotetype = new WellKnownClientTypeEntry(type,
                                "tcp://" + _Ip + ":" + _Port + "/" + type.Name + _Id + _Key);
                            RemotingConfiguration.RegisterWellKnownClientType(remotetype);
                            break;
                        }
                    }
                }
            }
        }