[Mono-list] Problem Accessing Embedded Resource

Jim Orcheson jim at va3hj.ca
Fri Apr 29 07:06:22 EDT 2011


No answers from anyone, but I did do some additional debugging.

I added the following line before the call to GetManifestResourceStream:

string[] resources = assembly.GetManifestResourceNames();

resources did contain "QslBureaus.QslBureaus.xml", as the first string 
so I substituted resources[0] in the call to GetManifestResourceStream 
and the code worked. I then replaced resources[0] with 
"QslBureaus.QslBureaus.xml" and the code worked.

I had copied the code from a VS2010 solution on Windows. A similar 
problem also occurred with the other library in my solution, so it 
appears the problem has to do with moving the files from VS2010 on 
Windows to MonoDevelop on Linux.

Jim

On 26/04/11 07:31 AM, Jim Orcheson wrote:
> I have created a solution consisting of a main program and two
> libraries. In one of the libraries I have included an XML file as an
> embedded resource. When I try to get a stream to read the XML file, the
> call to Assembly.GetManifestResourceStream returns null. mono version
> 2.6.7 is used to build the solution.
>
> See below for further information.
>
> The solution is called hamqsler.
> The library project is called QslBureaus, and the XML file is QslBureaus.xml
>
> The properties for QslBureaus.xml are as follows:
> Build action - Embed as resource
> Copy to output directory - Do not copy
> Resource ID - QslBureaus.QslBureaus.xml
>
> Name - QslBureaus.xml
> Path - /home/jim/Projects/hamqsler/QslBureaus/QslBureaus.xml
> Type - XML document
>
> Relative target path - QslBureaus.xml
> Target directory - Program files
>
> All other properties are not set.
>
> Here is the code that attempts to get the Stream:
> Assembly assembly = Assembly.GetAssembly(new QslBureau().GetType());
> Stream str =
> assembly.GetManifestResourceStream("QslBureaus.QslBureaus.xml");
>
> QslBureau is a class defined in the QslBureaus library.
>
> What is the correct name for the manifest resource? Neither
> QslBureaus.QslBureaus.xml nor hamqsler.QslBureaus.QslBureaus.xml works.
>
> Jim
>
> _______________________________________________
> Mono-list maillist  -  Mono-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list
>


More information about the Mono-list mailing list