c# - Assembly.GetManifestResourceStream not working with Xamarin on iOS -


the following code works fine in windows, however, when using xamarin , targeting ios, getmanifestresourcestream() returns null.

assembly assembly = assembly.getexecutingassembly(); stream stream = assembly.getmanifestresourcestream("communicationmodel.xmlschemas.devicecommon.xsd"); 

i have set file 'devicecommon.xsd' embedded resource. not sure why not returning valid stream.

does know why not working in ios using xamarin?

update:

ok, followed advice in comments , set file content.

i can detect file, cannot open it:

if (file.exists("devicecommon.xsd")) {   try   {     mystream = new filestream("devicecommon.xsd", filemode.open);   } .... } 

when run above code, 'file.exists()' call works, when attempt open it, following exception:

access path "/private/var/mobile/applications/8bd48d1f-f8e8-4a80-a446-f807c6728805/upnpui_ios.app/devicecommon.xsd" denied. 

anybody have ideas how can fix this???

thanks, curtis

ok, got work. in case, using same files windows .dll , xamarin.ios.dll. had named .dll projects differently, though namespaces same. unfortunately, microsoft documentation says use namespace part of filename. no true.. use .dll name part of namespace. slight difference, makes difference.

so, point.. set file properties to: 'embedded resource' , 'do not copy'. resources needed process files .xsd extension, looped through resource names , used ended in .xsd. way, no matter operating system on, name right because retrieved programmatically , didn't hard code it:

        assembly assembly = assembly.getexecutingassembly();         string[] resources = assembly.getmanifestresourcenames();         foreach (string resource in resources)         {             if(resource.endswith(".xsd"))             {                 stream stream = assembly.getmanifestresourcestream(resource);                 if (stream != null)                 {                     xmlschema schema = xmlschema.read(stream, null);                     _schemas.add(schema);                 }             }         } 

Comments

Popular posts from this blog

matlab - Deleting rows with specific rules -

php - MySQLi multi_query results for later use -