Meta Data not found when using a Windows Service

  • Thread starter Thread starter Nathan Kovac
  • Start date Start date
N

Nathan Kovac

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
 
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?
 
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)

Nathan Kovac said:
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
 
What's the identity of the service account?
Where are these dll's located?
What dependencies do they have?
What's are you using in AddAssembly to locate/load the DLL's?

Willy.



Nathan Kovac said:
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)

Nathan Kovac said:
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
 
I have inserted answers below. I won't be able to check this again until
tomorrow.


Willy Denoyette said:
What's the identity of the service account?

I don't know what you mean by identity of the service account. The name of
the service is StockMgrService. Where do I look for this Identity?
Where are these dll's located?
The dll's are installed to the same folder as the rest of the application.
What dependencies do they have?
SystemMethods.dll
System
System.Data
System.XML
using System;

using System.Data;

using System.Diagnostics;


RemoteLoader.dll
System
using System;

using System.Reflection;

wwScripting.dll
RemoteLoader
System
System.Data
using System;

using System.IO;

using System.Text;

using Microsoft.CSharp;

using Microsoft.VisualBasic;

using System.Reflection;

using System.Runtime.Remoting;

using System.CodeDom.Compiler;


What's are you using in AddAssembly to locate/load the DLL's?
/// <summary>

/// Adds an assembly to the compiled code

/// </summary>

/// <param name="lcAssemblyDll">DLL assembly file name</param>

/// <param name="lcNamespace">Namespace to add if any. Pass null if no
namespace is to be added</param>

public void AddAssembly(string lcAssemblyDll,string lcNamespace)

{

if (lcAssemblyDll==null && lcNamespace == null)

{

// *** clear out assemblies and namespaces

this.oParameters.ReferencedAssemblies.Clear();

this.cNamespaces = "";

return;

}


if (lcAssemblyDll != null)

this.oParameters.ReferencedAssemblies.Add(lcAssemblyDll);


if (lcNamespace != null)

if (this.cScriptingLanguage == "CSharp")

this.cNamespaces = this.cNamespaces + "using " + lcNamespace + ";\r\n";

else

this.cNamespaces = this.cNamespaces + "imports " + lcNamespace + "\r\n";

}

/// <summary>

/// Adds an assembly to the compiled code.

/// </summary>

/// <param name="lcAssemblyDll">DLL assembly file name</param>

public void AddAssembly(string lcAssemblyDll)

{

this.AddAssembly(lcAssemblyDll,null);

}

public void AddNamespace(string lcNamespace)

{

this.AddAssembly(null,lcNamespace);

}

public void AddDefaultAssemblies()

{

this.AddAssembly("System.dll","System");

this.AddNamespace("System.Reflection");

this.AddNamespace("System.IO");

}

Willy.



Nathan Kovac said:
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
 
I am not sure why this wasn't sent last week. Here it is again.

I have inserted answers below. I won't be able to check this again until
tomorrow.


Willy Denoyette said:
What's the identity of the service account?

I don't know what you mean by identity of the service account. The name of
the service is StockMgrService. Where do I look for this Identity?
Where are these dll's located?
The dll's are installed to the same folder as the rest of the application.
What dependencies do they have?
SystemMethods.dll
System
System.Data
System.XML
using System;

using System.Data;

using System.Diagnostics;


RemoteLoader.dll
System
using System;

using System.Reflection;

wwScripting.dll
RemoteLoader
System
System.Data
using System;

using System.IO;

using System.Text;

using Microsoft.CSharp;

using Microsoft.VisualBasic;

using System.Reflection;

using System.Runtime.Remoting;

using System.CodeDom.Compiler;


What's are you using in AddAssembly to locate/load the DLL's?
/// <summary>

/// Adds an assembly to the compiled code

/// </summary>

/// <param name="lcAssemblyDll">DLL assembly file name</param>

/// <param name="lcNamespace">Namespace to add if any. Pass null if no
namespace is to be added</param>

public void AddAssembly(string lcAssemblyDll,string lcNamespace)

{

if (lcAssemblyDll==null && lcNamespace == null)

{

// *** clear out assemblies and namespaces

this.oParameters.ReferencedAssemblies.Clear();

this.cNamespaces = "";

return;

}


if (lcAssemblyDll != null)

this.oParameters.ReferencedAssemblies.Add(lcAssemblyDll);


if (lcNamespace != null)

if (this.cScriptingLanguage == "CSharp")

this.cNamespaces = this.cNamespaces + "using " + lcNamespace + ";\r\n";

else

this.cNamespaces = this.cNamespaces + "imports " + lcNamespace + "\r\n";

}

/// <summary>

/// Adds an assembly to the compiled code.

/// </summary>

/// <param name="lcAssemblyDll">DLL assembly file name</param>

public void AddAssembly(string lcAssemblyDll)

{

this.AddAssembly(lcAssemblyDll,null);

}

public void AddNamespace(string lcNamespace)

{

this.AddAssembly(null,lcNamespace);

}

public void AddDefaultAssemblies()

{

this.AddAssembly("System.dll","System");

this.AddNamespace("System.Reflection");

this.AddNamespace("System.IO");

}

Willy.



Nathan Kovac said:
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
 
I keep posting a reply but it isn't going.

Willy Denoyette said:
What's the identity of the service account?
Where are these dll's located?
What dependencies do they have?
What's are you using in AddAssembly to locate/load the DLL's?

Willy.



Nathan Kovac said:
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
 
Back
Top