[Mono-devel-list] Embed xml files with mcs / get embedded xml file from Assembly with GetManifestResourceStream()

Hinrich Aue h_aue at gmx.de
Tue Apr 20 09:22:26 EDT 2004


I compiled the db layer of A .NET Application written with VisualStudio with 
mono.
The first Problem is that it seems the author embedded several xml files in 
the assemblies, and read them from the assembly during runtime:


Code #############################################
private void PrepareAllAdapters()
		{
			XmlDocument objXML = new XmlDocument();
			
objXML.Load(Assembly.GetExecutingAssembly().GetManifestResourceStream("MultimediaKnowledgeBase.DataAccessLayer.configadaptersearch.xml"));
			
PrepareAdapter(objXML.SelectSingleNode("adapters/adapter[@name='category']"), 
m_objAdapterCategory);
			
PrepareAdapter(objXML.SelectSingleNode("adapters/adapter[@name='booleansearch']"), 
m_objAdapterBooleanSearch);
			
PrepareAdapter(objXML.SelectSingleNode("adapters/adapter[@name='regularexpression']"), 
m_objAdapterRegExSearch);
			
PrepareAdapter(objXML.SelectSingleNode("adapters/adapter[@name='categorydocument']"), 
m_objAdapterCategoryDocument);
			
PrepareAdapter(objXML.SelectSingleNode("adapters/adapter[@name='refreshdocument']"), 
m_objAdapterRefreshDocument);
		}

 #############################################

When I start the Program, and use the above funktion (which I have to do 
during Init) I get following exception:

Exception ##########################################

Unhandled Exception: System.TypeInitializationException: An exception was 
thrown by the type initializer for 
MultimediaKnowledgeBase.DataAccessLayer.SearchHelper ---> 
System.NullReferenceException: Object reference not set to an instance of an 
object
in <0x0006a> Mono.Xml.Native.XmlInputStream:Initialize (System.IO.Stream)
in <0x00056> (wrapper remoting-invoke-with-check) 
Mono.Xml.Native.XmlInputStream:Initialize (System.IO.Stream)
in <0x00040> Mono.Xml.Native.XmlInputStream:.ctor (System.IO.Stream)
in <0x00056> (wrapper remoting-invoke-with-check) 
Mono.Xml.Native.XmlInputStream:.ctor (System.IO.Stream)
in <0x0002b> Mono.Xml.Native.XmlStreamReader:.ctor (System.IO.Stream)
in <0x00056> (wrapper remoting-invoke-with-check) 
Mono.Xml.Native.XmlStreamReader:.ctor (System.IO.Stream)
in <0x0002b> System.Xml.XmlTextReader:.ctor (System.IO.Stream)
in <0x00026> System.Xml.XmlDocument:Load (System.IO.Stream)
in <0x0005a> 
MultimediaKnowledgeBase.DataAccessLayer.SearchHelper:PrepareAllAdapters ()
in <0x000cd> MultimediaKnowledgeBase.DataAccessLayer.SearchHelper:.ctor ()
in <0x0001e> MultimediaKnowledgeBase.DataAccessLayer.SearchHelper:.cctor ()
--- End of inner exception stack trace ---

in (unmanaged) MKBTest:Main (string[])
##########################################

I embedded the xml files with the 
	-resource:FILE[,ID]     Embed FILE as a resource
option.
Is that correct? What is the ID for (I don't use ID)?
Or are there features missing in mono?

Thanks
	Hinrich.



More information about the Mono-devel-list mailing list