embedded resource file not found in assembly

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Steve Richter

    embedded resource file not found in assembly

    I am embedding an xml file in my class library assembly.

    In solution explorer I right click a folder, add , new item, xml file.

    then on the xml file I right click, properties, build action =
    embedded resource.

    build the class library, run the following code to access the XML as a
    stream:
    Stream cmdsStream =
    Assembly.GetExe cutingAssembly( ).GetManifestRe sourceStream(
    "AutoCoder.Ftp. FtpCommands.xml ");

    get back null. as in the resource stream is not found.

    so I go back to the class library project, rebuild all, and use
    ObjectBrowser to display the contents of the assembly. I dont see the
    xml embedded resource file. Looking everywhere, starting from the
    namespace of the folder I placed the file in.

    Did I embed the file incorrectly?

    thanks,

    -Steve

  • Nicholas Paldino [.NET/C# MVP]

    #2
    Re: embedded resource file not found in assembly

    Steve,

    You need to indicate a namespace for the file. Take a look at the
    "Applicatio n" tab in the project properties. Look at the "Default
    Namespace" textbox. That namespace is what you have to append before the
    "AutoCoder.Ftp. FtpCommands.xml " string in order to be able to retrieve the
    stream to your resource.

    If you look at your compiled binary in Reflector, you will see that the
    file does exist as a resource, with that namespace specified.

    Hope this helps.


    --
    - Nicholas Paldino [.NET/C# MVP]
    - mvp@spam.guard. caspershouse.co m

    "Steve Richter" <StephenRichter @gmail.comwrote in message
    news:1179278851 .352818.240850@ l77g2000hsb.goo glegroups.com.. .
    >I am embedding an xml file in my class library assembly.
    >
    In solution explorer I right click a folder, add , new item, xml file.
    >
    then on the xml file I right click, properties, build action =
    embedded resource.
    >
    build the class library, run the following code to access the XML as a
    stream:
    Stream cmdsStream =
    Assembly.GetExe cutingAssembly( ).GetManifestRe sourceStream(
    "AutoCoder.Ftp. FtpCommands.xml ");
    >
    get back null. as in the resource stream is not found.
    >
    so I go back to the class library project, rebuild all, and use
    ObjectBrowser to display the contents of the assembly. I dont see the
    xml embedded resource file. Looking everywhere, starting from the
    namespace of the folder I placed the file in.
    >
    Did I embed the file incorrectly?
    >
    thanks,
    >
    -Steve
    >

    Comment

    Working...