Xamarin : Loading resources via GetManifestResourceStream

有些话、适合烂在心里 提交于 2021-02-05 06:09:45

问题


I am working on a Xamarin forms project to use OpenGL/OpenTK. I am trying to load a shader using GetManifestResourceStream. Whatever I do I get null

code is being run from .Shared project, shaders are in .ios / .Android resources directory

string prefix;

#if __IOS__ 
prefix = "OpenGLTesting.iOS.";
#endif
#if __ANDROID__
prefix = "OpenGLTesting.Droid.";
#endif

var assembly = typeof(App).GetTypeInfo ().Assembly;
Stream stream = assembly.GetManifestResourceStream (prefix + shaderName + ".glsl");

回答1:


Add some debugging code, like calling assembly.GetManifestResourceNames (); so make sure you have both the right name and that it was embedded in your assembly.



来源:https://stackoverflow.com/questions/30917144/xamarin-loading-resources-via-getmanifestresourcestream

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!