<?xml version='1.0' encoding="utf-8"?>
      <rss version='2.0'>
      <channel>
      <title>Форум на Исходниках.RU</title>
      <link>https://forum.sources.ru</link>
      <description>Форум на Исходниках.RU</description>
      <generator>Форум на Исходниках.RU</generator>
  	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=172751&amp;view=findpost&amp;p=1479740</guid>
        <pubDate>Sat, 10 Mar 2007 09:59:04 +0000</pubDate>
        <title>.NET Remoting</title>
        <link>https://forum.sources.ru/index.php?showtopic=172751&amp;view=findpost&amp;p=1479740</link>
        <description><![CDATA[vo1d: Вопрос2: Запускается сервер, клиент получает объект, почему при остановке сервера не вызывается деструктор объекта? Как клиенту определить что соединение разорвано или сервер не работает?<br>
<br>
Вот код сервера для создания Client Activated Object:<br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">using System;</div><div class="code_line">using System.Runtime.Remoting;</div><div class="code_line">using System.Runtime.Remoting.Channels;</div><div class="code_line">using System.Runtime.Remoting.Channels.Tcp;</div><div class="code_line">&nbsp;</div><div class="code_line">namespace Test</div><div class="code_line">{</div><div class="code_line">&nbsp;&nbsp; &nbsp;public class Server</div><div class="code_line">&nbsp;&nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;private static int mPort = 60000;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;public static void Main(string[] args)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;try</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ChannelServices.RegisterChannel(new TcpChannel(mPort), true);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;RemotingConfiguration.RegisterActivatedServiceType(typeof(BusinessTier));</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Console.WriteLine(&quot;Server started on port &quot; + mPort);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;catch (Exception e)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Console.WriteLine(e);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Console.WriteLine(&quot;Press enter to exit...&quot;);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Console.ReadLine();</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}</div><div class="code_line">&nbsp;&nbsp; &nbsp;}</div><div class="code_line">}</div></ol></div></div></div></div><script>preloadCodeButtons('1');</script>]]></description>
        <author>vo1d</author>
        <category>.NET: Распределенные приложения</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=172751&amp;view=findpost&amp;p=1460254</guid>
        <pubDate>Wed, 21 Feb 2007 06:21:26 +0000</pubDate>
        <title>.NET Remoting</title>
        <link>https://forum.sources.ru/index.php?showtopic=172751&amp;view=findpost&amp;p=1460254</link>
        <description><![CDATA[vo1d: WellKnownObjectMode.Singleton не подходит т.к создает один объект для всех, а нужно - один объект на одного клиента UI.<br><br>Пока вижу 3 варианта:<br>-Не использовать Remoting, сделать все вручную (очень много писать :))<br>-Создать Singleton и вручную управлять объектами клиентов<br>-Запустить несколько серверов с Singleton]]></description>
        <author>vo1d</author>
        <category>.NET: Распределенные приложения</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=172751&amp;view=findpost&amp;p=1460096</guid>
        <pubDate>Tue, 20 Feb 2007 21:08:50 +0000</pubDate>
        <title>.NET Remoting</title>
        <link>https://forum.sources.ru/index.php?showtopic=172751&amp;view=findpost&amp;p=1460096</link>
        <description><![CDATA[cozzzy: Поменять WellKnownObjectMode.SingleCall на WellKnownObjectMode.Singleton?]]></description>
        <author>cozzzy</author>
        <category>.NET: Распределенные приложения</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=172751&amp;view=findpost&amp;p=1459968</guid>
        <pubDate>Tue, 20 Feb 2007 19:06:07 +0000</pubDate>
        <title>.NET Remoting</title>
        <link>https://forum.sources.ru/index.php?showtopic=172751&amp;view=findpost&amp;p=1459968</link>
        <description><![CDATA[vo1d: Делаю 3-tier(layer) приложение. Есть в качестве уровней выбрал схему СУБД-BusinessObject(BO)-UI. <br>
BO запускаю с помощью сервера:<br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">using System;</div><div class="code_line">using System.Runtime.Remoting;</div><div class="code_line">using System.Runtime.Remoting.Channels;</div><div class="code_line">using System.Runtime.Remoting.Channels.Tcp;</div><div class="code_line">&nbsp;</div><div class="code_line">namespace Test</div><div class="code_line">{</div><div class="code_line">&nbsp;&nbsp; &nbsp;public class Server</div><div class="code_line">&nbsp;&nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;private const int SVPORT = 60000;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;private const string SVURI = &quot;Test&quot;;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;public static void Main(string[] args)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;try</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;TcpChannel channel = new TcpChannel(SVPORT);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ChannelServices.RegisterChannel(channel, true);</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;RemotingConfiguration.RegisterWellKnownServiceType(</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;typeof(BusinessTier),</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SVURI,</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;WellKnownObjectMode.SingleCall);</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Console.WriteLine(&quot;Server started on port &quot; + SVPORT);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;catch (Exception e)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Console.WriteLine(e);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Console.WriteLine(&quot;Press enter to exit...&quot;);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Console.ReadLine();</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}</div><div class="code_line">&nbsp;&nbsp; &nbsp;}</div><div class="code_line">}</div></ol></div></div></div></div><br>
<br>
Проблема:<br>
Когда UI вызывает метод BO, создается новый экземпляр BO (для каждого вызова метода&#33;&#33;&#33;). А нужно чтобы для каждого UI создавался один BO (при подключении к серверу), который будет существовать до тех пор, пока UI его не уничтожит (т.е закроет соединение).<br>
<br>
Похоже на работу клиентов через терминалы, вся логика выполняется в BO который подключен к БД, а UI подключен к BO и вызывает методы - получает результаты.<br>
<br>
Например UI code:<br>
<br>
obj=(SomeObj)GetObject(...) // подключились и получили экземпляр BO<br>
obj.OpenDbConn(username, pass);<br>
obj.do_something1();<br>
...<br>
obj.do_something2();<br>
obj.CloseDbConn(); // больше BO не нужен<br>
<br>
Как реализовать?]]></description>
        <author>vo1d</author>
        <category>.NET: Распределенные приложения</category>
      </item>
	
      </channel>
      </rss>
	