NET Remoting www msdn microsoft com NET Remoting

  • Slides: 69
Download presentation

Спрощена архітектура. NET Remoting (www. msdn. microsoft. com) . NET Remoting 10

Спрощена архітектура. NET Remoting (www. msdn. microsoft. com) . NET Remoting 10

Приклад віддаленої (remoting) взаємодії (із серверним, remotable, класом Server. Object) (2/5) Serv. Host Server.

Приклад віддаленої (remoting) взаємодії (із серверним, remotable, класом Server. Object) (2/5) Serv. Host Server. Object – remotable-клас SObj_. vb - старий знайомий модуль vbc /t: library SObj_. vb SObj_. dll. NET Remoting 16

Приклад віддаленої (remoting) взаємодії (із серверним, remotable, класом Server. Object) (3/5) Сервер(хост) Serv. Host.

Приклад віддаленої (remoting) взаємодії (із серверним, remotable, класом Server. Object) (3/5) Сервер(хост) Serv. Host. cs Remoting-конфігурування csc /r: SObj_. dll Збірка з remotableкласом Server. Object . NET Remoting Serv. Host. cs Serv. Host. exe 17

Приклад віддаленої (remoting) взаємодії (із серверним, remotable, класом Server. Object) (4/5) Клієнт Фрагмент CForm_Conf.

Приклад віддаленої (remoting) взаємодії (із серверним, remotable, класом Server. Object) (4/5) Клієнт Фрагмент CForm_Conf. File_0. cs Remoting-конфігурування Проксі csc /r: SObj_. dll CForm_Сonf. File_0. cs Збірка з remotable класом Server. Object . NET Remoting CForm_Сonf. File_0. exe 18

Приклад віддаленої (remoting) взаємодії (із серверним, remotable, класом Server. Object) (5/5) Клієнт CForm_Conf. File_0.

Приклад віддаленої (remoting) взаємодії (із серверним, remotable, класом Server. Object) (5/5) Клієнт CForm_Conf. File_0. cs Remoting-конфігурування * Проксі csc /r: SObj_. dll CForm_Сonf. File_0. cs vbc /t: library SObj_. vb Server. Object – remotable-тип Сервер(хост) Serv. Host. cs SObj_. vb - старий знайомий модуль *. NET Remoting 19 csc /r: SObj_. dll Serv. Host. cs

Дослідження різних варіантів активізації (2/5) (клас Server. Object) ---> SObj. dll public class Server.

Дослідження різних варіантів активізації (2/5) (клас Server. Object) ---> SObj. dll public class Server. Object SObj. cs : Marshal. By. Ref. Object { private Guid m_guid; Віддалений Конструктор тип (клас) public Server. Object() { Server. Object m_guid = Guid. New. Guid(); Console. Write. Line( "Server. Object created. New temporal GUID: {0}", m_guid. To. String()); } public string Hi() { Метод Hi() Console. Write. Line( "Hi() method called. Temporal GUID is {0}", m_guid. To. String()); return "Hi!"; } }. NET Remoting 26

Програмне конфігурування на боці сервера Варіант серверної активізації (SAO) з режимом Singleton Channel. Services.

Програмне конфігурування на боці сервера Варіант серверної активізації (SAO) з режимом Singleton Channel. Services. Register. Channel(new Http. Channel(4000)); Remoting. Configuration. Register. Well. Known. Service. Type( typeof(Server. Object), "My. Server. Obj", Well. Known. Object. Mode. Singleton); URI Хост (фрагмент cs-кода) Варіант клієнтської активізації (СAO) Channel. Services. Register. Channel(new Http. Channel(4000)); Remoting. Configuration. Register. Activated. Service. Type( typeof(Server. Object)); Хост (фрагмент cs-кода). NET Remoting 38

Програмне конфігурування на боці клієнта Варіант серверної активізації (SAO) Remoting. Configuration. Register. Well. Known.

Програмне конфігурування на боці клієнта Варіант серверної активізації (SAO) Remoting. Configuration. Register. Well. Known. Client. Type( typeof(Server. Object), "http: //localhost: 4000/My. Server. Obj" ); // URL Розробка програм-клієнтів для режимів Singleton та Single. Call нічим URI не відрізняється Варіант клієнтської активізації (СAO) Remoting. Configuration. Register. Activated. Client. Type( typeof(Server. Object), "http: //localhost: 4000" ); // URL. NET Remoting 39

Хост на іншому комп'ютері. Режим Singleton … <application name="Serv"> <client> <wellknown url="http: //10. 1.

Хост на іншому комп'ютері. Режим Singleton … <application name="Serv"> <client> <wellknown url="http: //10. 1. 0. 75: 4000/My. Server. Obj" type="Server. Object, SObj"/> </client> <channels> <channel port="0" ref="http"/> </channels> …. NET Remoting 40

Створення проксі з використанням класу Activator (основа “динамічних викликів”) Варіант клієнтської активізації (СAO) object[]

Створення проксі з використанням класу Activator (основа “динамічних викликів”) Варіант клієнтської активізації (СAO) object[] url = {new Url. Attribute("http: //localhost: 4000/Serv")}; m_server = (Server. Object)Activator. Create. Instance( typeof(Server. Object), null, url); // Note that the second parameter (null) specifies // that no arguments are being passed m_server = (Server. Object)Activator. Get. Object( typeof(Server. Object), "http: //localhost: 4000/My. Server. Obj"); Варіант серверної активізації (SAO) . NET Remoting 42

Проект Fond. Ще один підхід. “Клас-пустушка” (class stand in – клас-дублер) using System; namespace

Проект Fond. Ще один підхід. “Клас-пустушка” (class stand in – клас-дублер) using System; namespace Server { public class Server. Object. F : Marshal. By. Ref. Object { // private int s = 0; public void Add () { //s += 1; throw new System. Not. Implemented. Exception(); } public int Total () { //return s; throw new System. Not. Implemented. Exception(); } } }. NET Remoting 51

Додаток . NET Remoting 57

Додаток . NET Remoting 57

Marshal. By. Ref. Object. Public Methods (www. msdn 2. microsoft. com/en-us/) . NET Remoting

Marshal. By. Ref. Object. Public Methods (www. msdn 2. microsoft. com/en-us/) . NET Remoting 58

Marshal. By. Ref. Object. Public Methods (www. msdn. microsoft. com/library/rus/) . NET Remoting 59

Marshal. By. Ref. Object. Public Methods (www. msdn. microsoft. com/library/rus/) . NET Remoting 59

Доінсталяція IIS (Internet Information Services) . NET Remoting 63

Доінсталяція IIS (Internet Information Services) . NET Remoting 63

Internet Information Services . NET Remoting 64

Internet Information Services . NET Remoting 64

Створення віртуального каталога Control Panel ->Administrative Tools -> Internet Information Services . NET Remoting

Створення віртуального каталога Control Panel ->Administrative Tools -> Internet Information Services . NET Remoting 65

Wizard . NET Remoting 66

Wizard . NET Remoting 66

Serialize My. Serializable. Class my. Object = new My. Serializable. Class(); // Insert code

Serialize My. Serializable. Class my. Object = new My. Serializable. Class(); // Insert code to set properties and fields of the object. Xml. Serializer my. Serializer = new Xml. Serializer(typeof(My. Serializable. Class)); // To write to a file, create a Stream. Writer object. Stream. Writer my. Writer = new Stream. Writer("my. File. Name. xml"); my. Serializer. Serialize(my. Writer, my. Object); my. Writer. Close(); Binary. Formatter fmt = new Binary. Formatter(); File. Stream fs = new File. Stream(name, File. Mode. Create, File. Access. Write, File. Share. None); fmt. Serialize(fs, get. Base(name)); fs. Close(); . NET Remoting 68

Deserialize My. Serializable. Class my. Object; // Construct an instance of the Xml. Serializer

Deserialize My. Serializable. Class my. Object; // Construct an instance of the Xml. Serializer with the type // of object that is being deserialized. Xml. Serializer my. Serializer = new Xml. Serializer(typeof(My. Serializable. Class)); // To read the file, create a File. Stream my. File. Stream = new File. Stream("my. File. Name. xml", File. Mode. Open); // Call the Deserialize method and cast to the object type. my. Object = (My. Serializable. Class) my. Serializer. Deserialize(my. File. Stream) Binary. Formatter fmt = new Binary. Formatter(); File. Stream fs = new File. Stream(name, File. Mode. Open, File. Access. Read, File. Share. Read); DBase db = fmt. Deserialize(fs) as DBase; fs. Close(); . NET Remoting 69