using System;
using System.Collections.Generic;
using System.Windows.Forms;
using Ubik.Remoting.Client;
using StoresAndStockPricing.Controls;
using System.Reflection;
using Ubik.Engine.Client;
namespace StoresAndStockPricing.Client{
static class Program
{
private static SessionRefreshTimer _timer;
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
string server = ProgramResources.Unknown;
try
{
server = new Properties.Settings().Server;
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.Automatic);
Application.ThreadException += Application_ThreadException;
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
// This belongs in a connection component
RemotingEndpoint endPoint = new RemotingEndpoint(server);
List<Assembly> modelAssemblies = new List<Assembly>();
modelAssemblies.Add(Assembly.Load("StoresAndStockPricing.Model"));
Session session = new Session(endPoint, modelAssemblies);
_timer = new SessionRefreshTimer(session);
_timer.Enabled = true;
Application.Run(new StoresAndStockPricingForm(session, server));
_timer.Enabled = false;
Application.ThreadException -= Application_ThreadException;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, ProgramResources.CouldNotConnectTo + server, MessageBoxButtons.OK, MessageBoxIcon.Error);
if (_timer != null && _timer.Enabled)
_timer.Enabled = false;
}
}
static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
{
MessageBox.Show(e.Exception.Message);
}
}
}
|