Click to See Complete Forum and Search --> : .NET Assemblies


rock
10-02-2003, 12:39 PM
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 (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconbuildingmulti-fileassembly.asp)) 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?

rock
10-02-2003, 03:37 PM
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:


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. :o