Re: Peer Network vs. Domain
From: Sunny (sunny_at_newsgroups.nospam)
Date: 07/20/04
- Next message: Sylvain Ross: "Re: Events on remote class and AddHandler"
- Previous message: Sunny: "Re: Remoting or windows service"
- In reply to: Howard Swope: "Peer Network vs. Domain"
- Next in thread: Howard Swope: "Re: Peer Network vs. Domain"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 20 Jul 2004 15:02:20 -0500
Hi,
and the exception is ...?
Sunny
In article <u3RJo3obEHA.796@TK2MSFTNGP09.phx.gbl>, "Howard Swope"
<howardsusenetATspitzincDOTcom> says...
> I am building an app that uses .Net remoting. My development machine is on
> the company domain, but the environment in which it will be deployed is a
> peer network. I test the app on any machine withing the domain and it works
> fine. Testing on any machine on the peer network throws an unhandled
> exception.
>
> I let only one instance of the application run. If someone fires a second
> instance off, I detect the first running instance and then use .Net remoting
> to pass the command line arguments from the newly run app to the already
> running app. The first instance will run fine on the peer network, but the
> second instance throws the unhandled exception. You can see the second
> instance specific code begin at [if (!granted)]. Any thoughts?
>
> static void Main(string[] args)
>
> {
>
> // turn off com security
>
> System.Threading.Thread.CurrentThread.ApartmentState =
> System.Threading.ApartmentState.STA;
>
> int ret = CoInitializeSecurity(IntPtr.Zero, -1, IntPtr.Zero,
> IntPtr.Zero, 1, 3, IntPtr.Zero, 0, IntPtr.Zero);
>
>
>
> // check to see if this is the first instance
>
> bool granted;
>
> Thread.CurrentThread.Priority = ThreadPriority.AboveNormal;
>
> Mutex firstInstanceMutex = new Mutex(true,"FirstControlPanelMutex",out
> granted);
>
> if (!granted)
>
> {
>
> Thread.CurrentThread.Priority = ThreadPriority.Normal;
>
> if (args.Length == 0)
>
> return;
>
>
>
> ChannelServices.RegisterChannel(new TcpChannel());
>
> SPControlPanel thePanel =
>
> (SPControlPanel)Activator.GetObject(typeof(SPControlPanel),"tcp://127.0.0.1:
> 8229/SPControlPanel");
>
> thePanel.AddToPlayList(args);
>
> return;
>
> }
>
>
>
> // Register channel services for remoting and the two root classes
>
> TcpServerChannel tsc = new TcpServerChannel(8229);
>
> ChannelServices.RegisterChannel(tsc);
>
>
> RemotingConfiguration.RegisterWellKnownServiceType(typeof(SPControlPanel),"S
> PControlPanel",WellKnownObjectMode.Singleton);
>
>
>
>
>
> //#if !DEBUG
>
> ExceptionHandler eh = new ExceptionHandler();
>
> Application.ThreadException += new
> ThreadExceptionEventHandler(eh.OnThreadException);
>
> //#endif
>
>
>
> Resources = new ResourceManager(typeof(SPControlPanel));
>
> MainWnd = new MainWindow();
>
> Monitor.Enter(MainWnd);
>
> MainWnd.AddPlayListItemsFromCommandLine(args);
>
> Application.Run(MainWnd);
>
> }
>
>
>
>
>
- Next message: Sylvain Ross: "Re: Events on remote class and AddHandler"
- Previous message: Sunny: "Re: Remoting or windows service"
- In reply to: Howard Swope: "Peer Network vs. Domain"
- Next in thread: Howard Swope: "Re: Peer Network vs. Domain"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|