Adding files to Assembly

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ron M. Newman

    Adding files to Assembly

    Hello .NET Sages,

    Question.

    What is the meaning of adding say, an XML file to a project, next to a .CS
    file (not that it matters). Does that mean the XML file becomes a part of
    the compiled assembly and I'll be able to refer to it from another
    application that'll open up and use this assembly?

    As you understand, this is my purpose. I'd like to have an assembly that
    builds with fixed XML files that I'd like to access from an application
    referring to this assembly. Is the way mentioned earlier the right way to do
    so? How do I retrieve the file later?

    Thanks
    Ron


  • Petar Repac

    #2
    Re: Adding files to Assembly

    Ron M. Newman wrote:
    Hello .NET Sages,
    >
    Question.
    >
    What is the meaning of adding say, an XML file to a project, next to a .CS
    file (not that it matters). Does that mean the XML file becomes a part of
    the compiled assembly and I'll be able to refer to it from another
    application that'll open up and use this assembly?
    >
    As you understand, this is my purpose. I'd like to have an assembly that
    builds with fixed XML files that I'd like to access from an application
    referring to this assembly. Is the way mentioned earlier the right way to do
    so? How do I retrieve the file later?
    >
    Thanks
    Ron
    >
    >
    Yes, the XML (bmp, ico, ...) file becomes part of the compiled assembly.
    If you use Reflector (http://www.aisto.com/roeder/dotnet/) tool you can
    open your assembly and you will find your file in Resources section.

    You add your file in C# project and then set BuildAction property to
    "EmbeddedResour ce". This way the file will be included into assembly,
    but not compiled.

    To access the content of the file use something like:
    StreamReader loStreamReader;
    loStreamReader = new
    StreamReader(As sembly.GetExecu tingAssembly(). GetManifestReso urceStream("MyN amespace.Data.X ML"));

    Replace "Assembly.GetEx ecutingAssembly ()" with some other way of getting
    System.Reflecti on.Assembly instance.

    Hope it helps,
    Petar Repac

    Comment

    • Ron M. Newman

      #3
      Re: Adding files to Assembly

      Thanks a bunch. Yes, this was the information I was looking for.
      Ron

      "Petar Repac" <petar.repac@re place_with_goog le_mail_service .comwrote in
      message news:e26H68z4GH A.4832@TK2MSFTN GP06.phx.gbl...
      Ron M. Newman wrote:
      >Hello .NET Sages,
      >>
      >Question.
      >>
      >What is the meaning of adding say, an XML file to a project, next to a
      >.CS file (not that it matters). Does that mean the XML file becomes a
      >part of the compiled assembly and I'll be able to refer to it from
      >another application that'll open up and use this assembly?
      >>
      >As you understand, this is my purpose. I'd like to have an assembly that
      >builds with fixed XML files that I'd like to access from an application
      >referring to this assembly. Is the way mentioned earlier the right way to
      >do so? How do I retrieve the file later?
      >>
      >Thanks
      >Ron
      >>
      >>
      >
      Yes, the XML (bmp, ico, ...) file becomes part of the compiled assembly.
      If you use Reflector (http://www.aisto.com/roeder/dotnet/) tool you can
      open your assembly and you will find your file in Resources section.
      >
      You add your file in C# project and then set BuildAction property to
      "EmbeddedResour ce". This way the file will be included into assembly, but
      not compiled.
      >
      To access the content of the file use something like:
      StreamReader loStreamReader;
      loStreamReader = new
      StreamReader(As sembly.GetExecu tingAssembly(). GetManifestReso urceStream("MyN amespace.Data.X ML"));
      >
      Replace "Assembly.GetEx ecutingAssembly ()" with some other way of getting
      System.Reflecti on.Assembly instance.
      >
      Hope it helps,
      Petar Repac

      Comment

      Working...