J
Jay Pondy
I have a class library project that is being used in an ASP.Net web site.
In the library class I have several files containing SQL statements (in a
sql subdirectory) with their 'Build Action' property set to Embedded Resource.
I use the following code to retrieve the SQL statements from these embedded
resources at runtime:
protected string SQLFetch(string fileName)
{
Assembly assembly = Assembly.GetEntryAssembly();
Trace.Assert(assembly != null);
string assemblyName = assembly.GetName().Name;
string resourceName = string.Format("{0}.sql.{1}", assemblyName, fileName);
// Assembly.directory.filename
Trace.Assert(resourceName != null);
Stream stream = assembly.GetManifestResourceStream(resourceName);
string sql = string.Empty;
if (stream == null)
throw new ApplicationException(string.Format("Missing resource '{0}'.",
resourceName));
else
{
using (StreamReader rdr = new StreamReader(stream))
{
sql = rdr.ReadToEnd();
}
return sql;
}
}
When I attempt to call into this library from an ASP.Net web site the
assembly is being returned as NULL.
What do I need to do to either correct this problem or work around it?
In the library class I have several files containing SQL statements (in a
sql subdirectory) with their 'Build Action' property set to Embedded Resource.
I use the following code to retrieve the SQL statements from these embedded
resources at runtime:
protected string SQLFetch(string fileName)
{
Assembly assembly = Assembly.GetEntryAssembly();
Trace.Assert(assembly != null);
string assemblyName = assembly.GetName().Name;
string resourceName = string.Format("{0}.sql.{1}", assemblyName, fileName);
// Assembly.directory.filename
Trace.Assert(resourceName != null);
Stream stream = assembly.GetManifestResourceStream(resourceName);
string sql = string.Empty;
if (stream == null)
throw new ApplicationException(string.Format("Missing resource '{0}'.",
resourceName));
else
{
using (StreamReader rdr = new StreamReader(stream))
{
sql = rdr.ReadToEnd();
}
return sql;
}
}
When I attempt to call into this library from an ASP.Net web site the
assembly is being returned as NULL.
What do I need to do to either correct this problem or work around it?