Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
| Search | Today's Posts | Mark Forums Read
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old March 23rd, 2007, 12:58 AM
Registered User
 
Join Date: Mar 2007
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default NET Remoting problem

Hi, here some code:

----------------------------------------------------------------------------
// remoting server
using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;

namespace Test
{
    public class Server
    {
        private static int mPort = 60000;

        public static void Main(string[] args)
        {
            try
            {
                ChannelServices.RegisterChannel(new TcpChannel(mPort), true);
                RemotingConfiguration.RegisterActivatedServiceType (typeof(BusinessTier));
                Console.WriteLine("Server started on port " + mPort);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

            Console.WriteLine("Press enter to exit...");
            Console.ReadLine();
        }
    }
}

----------------------------------------------------------------------------
// client activated object
using System;
using System.Collections;
using System.IO;
using System.Runtime.Remoting;

namespace Test
{
    public class BusinessTier : MarshalByRefObject
    {
        public BusinessTier()
        {
        }

        public bool Connect(string user, string pass)
        {
            // connect to database
        }

        private void Dispose(bool disposing)
        {
            // close connection
        }

        public void Dispose()
        {
            Dispose(true);
            GC.SuppressFinalize(this);
        }

        ~BusinessTier()
        {
            Dispose(false);
        }
    }
}

----------------------------------------------------------------------------
// client application
...
ChannelServices.RegisterChannel(new TcpChannel(), true);
RemotingConfiguration.RegisterActivatedClientType(
    new ActivatedClientTypeEntry(typeof(BusinessTier), SERVER));

mBsTier = new BusinessTier();
mBsTier.Connect(user, pass);
...

----------------------------------------------------------------------------
Problem:
Why server don't call BusinessTier.Dispose() when it stopped or client disconnected by timeout?


Similar Threads
Thread Thread Starter Forum Replies Last Post
.net remoting problem while hosting in public IIS dotnetpranker C# 3 March 19th, 2007 07:05 AM
.NET Remoting manisha2578 VB.NET 0 May 9th, 2005 11:23 PM
.Net Remoting Problem farhan_iac General .NET 0 June 11th, 2004 03:13 AM
.NET Remoting application in vb.net Tek4VB .NET Web Services 6 November 19th, 2003 09:59 AM
.NET Enterprise Development in VB.NET Remoting burkert All Other Wrox Books 0 June 24th, 2003 09:04 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.