Scripting Methods.dll I wrote from scratch.
RemoteLoader.dll and wwScripting.dll are mostly code snippets from others
have done online.
In 'DatabaseManager.DataComponent' which is one I wrote I have the
following method. Notice the error handling. All I logged was
e.Message. If you think I should grab more information for next time
please let me know. When I was debugging with a windows form I was
logging to a file. When I made it a service I discovered I couldn't do
that, and at the time I got these errors I was simply having log dump to
the Debug.WriteLine. I will have it logging to Sql soon.
public void RunEventsByStockID(int stockID, int eventTypeID, int
accountID)
{
//Use AccountID=0 to execute event on all accounts
RefreshEventList();
foreach (StockData.EventListRow r in stockData2.EventList)
{
if (r.StockID==stockID && r.EventTypeID==eventTypeID && (accountID==0 ||
accountID==r.AccountID))
{
wwScripting loScript = new wwScripting(r.EventLanguage);
// loScript.CreateAppDomain("MyAppDomain")
// Add any assemblies referenced
loScript.AddAssembly("ScriptingMethods.dll");
loScript.AddNamespace("ScriptingMethods");
System.Text.StringBuilder sb=new System.Text.StringBuilder("");
sb.Append("public string ExecEvent(int accountID, int eventTypeID, int
stockID, string sqlConnectionString) {");
sb.Append("\r\n");
sb.Append("ScriptingMethods.StockMethods Stock=new
ScriptingMethods.StockMethods(accountID, eventTypeID, stockID,
sqlConnectionString);");
sb.Append("\r\n");
sb.Append("ScriptingMethods.AccountMethods Account=new
ScriptingMethods.AccountMethods(accountID, eventTypeID,
sqlConnectionString);");
sb.Append("\r\n");
sb.Append(@"string LogMessage=""Blank Log Message"";");
sb.Append("\r\n");
sb.Append(r.EventCode);
sb.Append("\r\n");
sb.Append("return LogMessage;");
sb.Append("\r\n");
sb.Append("}");
sb.Append("\r\n");
string code=sb.ToString();
object objResult=loScript.ExecuteMethod(code, "ExecEvent", r.AccountID,
r.EventTypeID, r.StockID, this.sqlConnectionString);
string lcResult;
try{
lcResult=(string) objResult;
}
catch(Exception e)
{
lcResult=e.Message;
}
if (loScript.bError)
{
log.LogText(this.ToString(),"Error",loScript.cErrorMsg);
}
else
{
if(lcResult.Length>0)
log.LogText(this.ToString(),"Result",lcResult);
}
loScript.Dispose();
}
}
}
Nicholas Paldino said:
Nathan,
Are all of these your dlls? Are these exceptions that are being
thrown and logged? If so, what are the types of the exceptions, as well
as the other details?
--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)
Yesterday afternoon I was getting the following errors in a windows
service:
'DatabaseManager.DataComponent', 'Error', '3 Errors:
Line: 0 - Metadata file 'ScriptingMethods.dll' could not be found
Line: 0 - Metadata file 'RemoteLoader.dll' could not be found
Line: 0 - Metadata file 'wwScripting.dll' could not be found'
Service ran all night fine. This morning I reconnected to the process
and the errors are no longer there. Only thing I can think of is if
logging off and back on did something. I should also note that
yesterday visual studio crashed on me when I had the solution open and
tried to connect to the windows service project.
Does anyone with a better understanding of the CLR have any possible
explaination for the inconsistant errors?
Thanks,
Nathan