Quantcast
Channel: XML, System.Xml, MSXML and XmlLite forum
Viewing all articles
Browse latest Browse all 935

GetManifestResourceStream returns null in xsl c# extension function, works fine in C# project

$
0
0

I see GetManifestResourceStream return null in a xsl c# extension function. The same code works as expected when run in C# project. Code below.

I ran into a post mentioning ReflectionPermissionFlag.MemberAccess, but it is not clear to me how this has an effect, or how to apply it in this case.

Any ideas?

<msxsl:script language="C#" implements-prefix="user"><![CDATA[
      public string parse_myfile(string id)
        {
            string desc = "bad";

            try
            {
                using (System.IO.Stream strm = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("myproj.resources.myfile.txt"))
                using (System.IO.StreamReader file = new System.IO.StreamReader(strm))
                {
                    desc = "good";
                }
            }
            catch (Exception e)
            {
                var t = e.GetType();
                while (t != null)
                {
                    Console.WriteLine(t.AssemblyQualifiedName);
                    t = t.BaseType;
                }
            }
            return desc;
        }
      ]]></msxsl:script>



Viewing all articles
Browse latest Browse all 935

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>