jeudi 28 mai 2020

Assembly reflection problem in Release mode

I'm facing some weird behaviour trying to get the parent assembly in some logging class (only when it's compiled in Release mode).

In Debug mode this works like a charm:

            StackFrame[] frames = new StackTrace().GetFrames();
            var assemblies = (from f in frames
                              select f.GetMethod().ReflectedType.Assembly)
                                    .Distinct()
                                    .Last();

Example: assembly A => assembly B => method

when I run the above script in debug mode I get assembly A (as expected) but when it runs in release mode I get: mscorlib instead. but the most weird thing is that if a check for the whole assemblies stack there is not a single reference of assembly A. how is this possible? what can be happening?

PS: assembly A is a webapp project.





Aucun commentaire:

Enregistrer un commentaire