System.Xml.Dll assembly only loading on breakpoint

MatthieuDMatthieuD Member ✭✭

Hello,

I have been migrating all my project from an old version of xamarin with an old version of mono to the latest of both.
Amongst all the other issues I have encountered and found a solution, here is one I am still stuck with.

When I start my application on Debug, some part of a code sends an exception:
var source = new TraceSource(traceName);
source.Listeners.Clear();

The source.Listeners.Clear(); says the following:
System.MissingMethodException: Default constructor not found for type System.Diagnostics.FilterElements

Here comes the funny part: if I put a breakpoint on this line, and hoover the "Listeners" word, I got the error above on a little warning windows. But meanwhile in the logs of the application, the DLL loads himself (at the same moment I hoover the word):
Loaded assembly: /Users/...../System.Xml.dll [External]

And then the application runs smoothly, without errors, and the listeners work.

If I don't put the breakpoint, the application will not run properly.

Any idea on this one?

N.B.: I have migrated the application so it compiles in 64bits, retargeted a bunch of packages, etc. So Maybe I have broken something, but I have no idea what.

Best Answer

  • MatthieuDMatthieuD ✭✭
    Accepted Answer

    The issue disappeared after I successfully unified the mono APIs.
    I will close it.
    Thanks for your answers though, it helped me a lot.

Answers

  • ChrisHamonsChrisHamons USForum Administrator, Xamarin Team Xamurai

    Hmm, that seems strange. My guess is that somehow debugging is changing how assemblies are loaded between the two use cases.

    • Have you tried adding a reference to System.Xml.dll to your project?
    • You could try launching with MONO_LOG_LEVEL=debug MONO_LOG_MASK=asm environmental variables set from the command line add see if you get any spam around the failing case.

    If you can isolate this to a small test case you can also file a bug for us to look at. MissingMethodException seems wrong.

  • MatthieuDMatthieuD Member ✭✭
    edited February 7

    System.Xml.Dll is already referenced to the project.

    How do I add these 2 variables by command line using the IDE?

    I will try to create a project to reproduce the problem.

    EDIT: I tried to recreate the problem into a new project (of a new solution, outside mine) and the dll properly loads.
    So I guess I cannot create a dummy project to send for a report at this moment... Will continue searching though.

  • ChrisHamonsChrisHamons USForum Administrator, Xamarin Team Xamurai

    You can set it in the project options:

  • MatthieuDMatthieuD Member ✭✭
    Accepted Answer

    The issue disappeared after I successfully unified the mono APIs.
    I will close it.
    Thanks for your answers though, it helped me a lot.

Sign In or Register to comment.