Search code examples
c#xsltembedded-resource

Can't find .XSL file embedded in project DLL


Quick question that's wrecked my morning and is driving me nuts.

I have a small project that includes a DLL from another project. The DLL has an XSL file embedded in it that I want to extract and apply to a webbrowser control.

I have no problem with extracting / accessing embedded resources in the main EXE file, but I cannot find the means of accessing it in the DLL!?

I've tried:

  • "SolutionName.DllName.Resource.xsl"
  • "ExeName.DllName.Resource.xsl"
  • "ProjectNamespace.DllNamespace.Resource.xsl"

...and pretty much every permutation thereof, but it's never able to find it.

I don't have a dot-notation reference for it in C# to use with nameof(), and I can't find any apparent reference / access to it with:

System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceNames();

So, what's the correct naming (or other?) method for retrieving this file?

In case any of this helps, here's some additional details:

Project Name: DataBuilder
Project Namespace: DataBuilder
DLL Name: CobCommon
DLL Namespaces: CobCommon, CobCommon.Classes, CobCommon.Classes.Data, CobCommon.Winforms, CobCommon.WinForms.Controls
XSL Resource Name: XmlFormating.xsl

The specified resource file operation is "Embedded Resource" and it's located in the "root" area of the DLL project.

Accessing global:: gives me CobCommon, and DataBuilder amongst the available choices, but CobCommon doesn't have either a .Properties or a .Resources option, and DataBuilder which does have .Properties.Resources gives "Culture" as the only reference.

The XSL file is listed on the DLL Project's "Properties|Resources|Files" tab.

What am I missing?


Solution

  • Using GetExecutingAssembly() will probably always refer to your assembly. Instead, create an instance of some innocuous, (hopefully) simple object declared in that external DLL, then use that instance object's...

    <object-from-DLL>.GetType().Assembly.GetManifestResourceStream("what.youre.looking.for") 
    

    to get a stream handle to your embedded object.