.NET Assemblies

Sharky Forums


Results 1 to 2 of 2

Thread: .NET Assemblies

  1. #1
    NullPointerException rock's Avatar
    Join Date
    Sep 2000
    Location
    York, PA
    Posts
    6,203

    .NET Assemblies

    I'm having a bear of a time finding any info about this online - maybe somebody here can help. I've tried searching some c# forums, but the ones I've found haven't addressed this.

    In Java, I can easily include extra files in a jar file (like .csv data files). It's trivial in the construction of the jar file and doesn't even involve the manifest.

    Now, in .NET, all these things are "assemblies" and I've found instructions on how to create multi-file assemblies (here) but this is only for creating .netmodule files out of source code and combining them into one .exe. There's no mention of adding in data files. The command line linker (al.exe) doesn't have any options except for embedding resource files (which a data file isn't).

    Anybody know anything about this?

    Open Source is free like a puppy is free.

    It's only when you look at an ant through a magnifying glass on a sunny day that you realise how often they burst into flames.

    Understanding Evolution

  2. #2
    NullPointerException rock's Avatar
    Join Date
    Sep 2000
    Location
    York, PA
    Posts
    6,203
    Well, I finally figured it out. In case anyone else ever needs this:

    Add the file to your project in the Solution Explorer view by choosing Add>Add Existing Item...

    Now, it should be in that list, so right-click it and choose Properties.

    Here (the key) change BuildAction to Embedded Resource.

    Now it will be part of the .exe. The trick now is getting to it. Similar to Java, you just need the full resource name. Similar to this:

    Code:
                Stream str = GetType().Module.Assembly.GetManifestResourceStream("MyNameSpace.data.csv");
                StreamReader sr = new StreamReader(str);
    In java, the full name would usually just start as would a Classpath. Here, you need the whole NameSpace for the project then the filename with any directory in front. This example has it in the root of the namespace, so no directory is there.


    Learning new languages on your own is tough work.

    Open Source is free like a puppy is free.

    It's only when you look at an ant through a magnifying glass on a sunny day that you realise how often they burst into flames.

    Understanding Evolution

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •