I have a file name, like \"Foo.dll,\" for a library that I know is in the bin directory. I want to create an Assembly object for it. I\'m trying to instantiate this object from
A complete example as I use, if it helps. Resources is a folder under the root of the DLL Library (Assembly)
public static string ReadAssemblyResourceFile(string resourcefilename)
{
using (var stream = Assembly.Load("GM.B2U.DAL").GetManifestResourceStream("GM.B2U.DAL.Resources."
+ resourcefilename)) {
if (stream == null) throw new MyExceptionDoNotLog($"GM.B2U.DAL.Resources.{resourcefilename} not found in the Assembly GM.B2U.DAL.dll !");
using (var reader = new StreamReader(stream))
{
return reader.ReadToEnd();
}
}
}
to call the function:
[TestMethod()]
public void ReadAssemblyResourceFileTest()
{
var res = SetupEngine.ReadAssemblyResourceFile("newdb.sql");
Assert.IsNotNull(res);
}
ps. Do not forget to to mark the "Build Action" as "Embedded Resource" (in the properties window) of each resource file.