In the fragment below, the CodeBase property fails on the assembly System.Xml.Xsl.CompiledQuery, no where else. The message says that “The invoked member is not supported in a dynamic assembly”.
I get that the CodeBase property is not implemented, what I don’t get is why all of a sudden this is a problem. This code has been in service for months without a problem and suddenly …
if( CompareCaseInsensitive( Path.GetFileNameWithoutExtension( assembly.CodeBase ), namespaceURI ) )
return assembly;
I have several options available to code around this, but I’m hoping that someone can explain what happened in a way that might lead to a more robust solution.
Edited with a follow on question.
Is there some way to tell which assemblies have this property implemented and which do not without resorting to exceptions?
Any code that’s generated with System.Reflection.Emit namespace classes won’t have a CodeBase. Since the code wasn’t loaded from an assembly, it was generated at runtime. That certainly includes System.Xml.Xsl classes, they do use the internal System.Xml.Xsl.XmlILGenerator class which heavily leans on System.Xml.Xsl.IlGen. Lots of Reflection.Emit code there.
I cannot guess why this worked before. Maybe .NET 4.0, not sure.