Thursday, October 3, 2013

Error 1503 on lunching windows service

@PaulDAndrea, sorry my ignorance. I still don't understand. I have an application in the service. Originally the code was



protected override void OnStart(string[] args)
{
IvrApplication.Start();
}

// And for the Ivrpplication, we have
public class IvrApplication
{
private static object s_SyncVar = new object();
public static object SyncVar
{
get { return IvrApplication.s_SyncVar; }
}

private static Log s_Log;
public static Log Log
{
get { return s_Log; }
}

private static State s_State;

public static State State
{
get { return s_State; }
}

private static Thread s_MainCodeThread;

public static Thread MainCodeThread
{
get { return s_MainCodeThread; }
}

private static AutoResetEvent s_ThreadEvent = new AutoResetEvent(false);

public static AutoResetEvent ThreadEvent
{
get { return s_ThreadEvent; }
}

private static string s_WorkingFolder = null;

public static string WorkingFolder
{
get { return s_WorkingFolder; }
}



static IvrApplication()
{
// Constructor
s_Log = new Log("IvrApplication.Log");
Log.Write("IvrApplication Constructor Complete");
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

}

static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
if (e.ExceptionObject is Exception)
{
Log.WriteException((Exception)e.ExceptionObject, "Domain Level Unhandled Exception");
}
else
{
Log.Write("Domain Level Unhandled Exception - No Exception Object");
}
}

public static void Start()
{

lock (SyncVar)
{
if (State == State.Stopped)
{
s_State = State.Starting;
ThreadStart ts = new ThreadStart(MainCode);
s_MainCodeThread = new Thread(ts);
s_MainCodeThread.Name = "IvrApplication";
s_MainCodeThread.Start();
Log.Write("IvrApplication Starting...");
}

If we cannot put

IvrApplication.Start();

inside OnStart(), where is the place to go? Need code help.


No comments:

Post a Comment