powered by simpleCommunicator - 2.0.49     © 2025 Programmizd 02
Форумы / WCF, Web Services, Remoting [игнор отключен] [закрыт для гостей] / Вопрос по Remoting
8 сообщений из 8, страница 1 из 1
Вопрос по Remoting
    #32782827
Shultze
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
На сервере регистрирую
Код: plaintext
1.
2.
3.
TcpChannel channel = new TcpChannel(channelProperties, new BinaryClientFormatterSinkProvider(),new BinaryServerFormatterSinkProvider());
ChannelServices.RegisterChannel(channel); 
RemotingConfiguration.RegisterActivatedServiceType(typeof(sqlDataStorage));
sqlDataStorage описан:
Код: plaintext
1.
public class sqlDataStorage: MarshalByRefObject, IContractStorage

IContractStorage лежит в отдельной сборке, на которую ссылается и клиент и сервер

Клиентом пытаюсь создать объект
Код: plaintext
1.
2.
3.
TcpChannel channel = new TcpChannel(channelProperties, new BinaryClientFormatterSinkProvider(),new BinaryServerFormatterSinkProvider());
ChannelServices.RegisterChannel(channel); 
RemotingConfiguration.RegisterActivatedClientType(typeof(IContractStorage),"tcp://localhost:888");

и вот дальше то ступор... Activator не подходит, так как он пытается создать объект зарегистрированный в WellKnown типах, а в этом случае регистрируется Client Activation object. Вопрос снимается если переношу классы в отдельную сборку, но хочется ведь не плодить лишний код на клиенте.
...
Рейтинг: 0 / 0
Вопрос по Remoting
    #32783017
taj
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
По моему в MSDN в разделе по Activator.CreateInstance описано именно то, что тебе нужно, а именно получение интерфейса из удаленного объекта с клиентской активацией, используя UrlAttribute - глянь еще разок повнимательнее.
...
Рейтинг: 0 / 0
Вопрос по Remoting
    #32783709
Shultze
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Глядел, не получается...

Дает исключение System.Reflection.TargetInvocationException
где-то что-то не так делаю
...
Рейтинг: 0 / 0
Вопрос по Remoting
    #32783756
Shultze
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
object[] activationAttributes = {new UrlAttribute("tcp://localhost:888");}ObjectHandle hStorage = Activator.CreateInstance("IntfLib", 
"Contracts.sqlDataStorage",
true,
BindingFlags.Instance|BindingFlags.Public,
null,
null,
null,
activationAttributes,
null);
Storage = (IContractStorage) hStorage.Unwrap();							 null);

Получилось, объект создается, но на клиенте требуется сборка в которой содержится класс sqlDataStorage, а цель избавится от серверного кода на клиенте.
...
Рейтинг: 0 / 0
Вопрос по Remoting
    #32783775
кузя
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Shultzeцель избавится от серверного кода на клиенте.
используй soapsuds или сам через System.Runtime.Remoting.MetadataServices генери сборку-заглушку (только метаданные серверной сборки)
...
Рейтинг: 0 / 0
Вопрос по Remoting
    #32785300
кузя
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
PS.
если делать все на интерфейсах, то у тебя на сервере должен быть один или несколько SAO который(е) будет являться фабрикой по созданию CAO и возвращать на клиента интерфесы создаваемых на сервере объектов.

----
и, наконец, избавишься от этой серверной сборки (в любом её виде) на клиенте.
...
Рейтинг: 0 / 0
Вопрос по Remoting
    #32908036
Василий Д.
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Такой вопрос. Естб код:

class1.cs
Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
using System;

namespace RemotingType
{
	/// <summary>
	/// Summary description for Class1.
	/// </summary>
	/// 
	public class Class2:MarshalByRefObject
	{
		public int a=1;
		public Class2()
		{
		}
	}
	public class Class1:MarshalByRefObject
	{
		public Class1()
		{
			//
			// TODO: Add constructor logic here
			//
		}
		public Class2 getClass2()
		{
			
			return new Class2();
		}
		public void AddSumm( Class2 asdf)
		{
			//asdf.a+=123;
			asdf=new Class2();
		}
	}
}


Listener.cs
Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
using System;
using System.Runtime.Remoting;
namespace Listener
{
	public class Start
	{
		[STAThread]
		static void Main() 
		{
			RemotingConfiguration.Configure("Listener.exe.config");
			Console.WriteLine("Press ENTER to end remoting");
			Console.ReadLine();
		}
	}
}


Client.cs
Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
using System;
using RemotingType;
using System.Runtime.Remoting;
namespace RemotingClient
{
	/// <summary>
	/// Summary description for Class1.
	/// </summary>
	class Class1
	{
		/// <summary>
		/// The main entry point for the application.
		/// </summary>
		[STAThread]
		static void Main(string[] args)
		{
			RemotingConfiguration.Configure("RemotingClient.exe.config");

			RemotingType.Class1 cls=new RemotingType.Class1();

			Class2 cl2,cl3;
			cl3=cls.getClass2();
			cls.AddSumm(cl3);
			//
			// TODO: Add code to start application here
			//
		}
	}
}

RemotingClient.exe.config

Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
<configuration>
   <system.runtime.remoting>
      <application>
         <client>
            <wellknown 
               type="RemotingType.Class1, RemotingType"
               url="http://localhost:8989/RemotingType.rem"
            />
         </client>
      </application>
   </system.runtime.remoting>
</configuration>

Listener.exe.config
Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
<configuration>
   <system.runtime.remoting>
      <application>
         <service>
            <wellknown 
               mode="Singleton" 
               type="RemotingType.Class1, RemotingType" 
               objectUri="RemotingType.rem"
            />
         </service>
         <channels>
            <channel ref="http" port="8989"/>
         </channels>
      </application>
   </system.runtime.remoting>
</configuration>

При выполнении срочки cls.AddSumm(cl3);
выкидывается сообщение об ошибке : n unhandled exception of type 'System.Runtime.Serialization.SerializationException' occurred in mscorlib.dll

Additional information: Because of security restrictions, the type System.Runtime.Remoting.ObjRef cannot be accessed.
Что делать???
...
Рейтинг: 0 / 0
Вопрос по Remoting
    #32908156
Alexey Kudinov
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Василий Д.Additional information: Because of security restrictions, the type System.Runtime.Remoting.ObjRef cannot be accessed.
Что делать???
http://www.thinktecture.com/Resources/RemotingFAQ/Changes2003.html
...
Рейтинг: 0 / 0
8 сообщений из 8, страница 1 из 1
Форумы / WCF, Web Services, Remoting [игнор отключен] [закрыт для гостей] / Вопрос по Remoting
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]