Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InvalidProgramException; "Common Language Runtime detected an invalid program." #110

Open
cameron-foreflight opened this issue Mar 11, 2021 · 10 comments

Comments

@cameron-foreflight
Copy link

Running my project in Release mode with Tracer.Serilog.Fody weaved in causes this exception on startup. When I remove the weaver from my FodyWeavers.xml or switch to Debug mode, the app continues running just fine.

@csnemes
Copy link
Owner

csnemes commented Mar 15, 2021

Could you please run PEVerify on the release mode assembly?

@cameron-foreflight
Copy link
Author

Getting a bunch of The system cannot find the file specified. errors whenever I run PEVerify on the assembly, both with Tracer and without. Don't have a lot of experience using this tool, what specifically are you looking for?

@csnemes
Copy link
Owner

csnemes commented Mar 16, 2021

The reason for the invalid program exception is that Tracer messes up the IL code when adding trace functionality. PEVerify tool can check if the IL code and the metadata in the assembly are correct and can point out any problem. PEVerify can be run from developer's command prompt if you're using Visual Studio. I need to figure out what construct in your code causes this problem.

@cameron-foreflight
Copy link
Author

Not finding a lot on PEVerify, so just don't know what is causing all of the The system cannot find the file specified. errors when I run from command prompt. I am getting this both without Tracer weaved in and with Tracer weaved in.

@csnemes
Copy link
Owner

csnemes commented Mar 17, 2021

Another option would be to add VerifyAssembly="true" to the Weavers element in the FodyWeavers.xml. It should run this PE verification after weaving and output the problem.

@cameron-foreflight
Copy link
Author

Added that and built, and now have a lot of Unable to resolve token.(Error: 0x80131869) messages. Using ILSpy, I'm able to go in and see those methods and constructors and ensure they exist though.

@cameron-foreflight
Copy link
Author

Should PEVerify, and Tracer.Serilog for that matter, work for UWP projects?

@csnemes
Copy link
Owner

csnemes commented Mar 19, 2021

Theoretically yes, but I've never tried it. Are you using some special language construct where this error appears? Could you give some minimal reproduction source code so I can debug into it? Anyway I'll create a small UWP project and check if it can be rewritten with tracer.

@cameron-foreflight
Copy link
Author

No special language construct that I'm aware of. I'll see if I can put something together, but won't have a lot of time this week. Were you able to check Tracer with a small UWP project?

@csnemes
Copy link
Owner

csnemes commented Mar 23, 2021

I created a minimal UWP (just some buttons on a screen) and it works both in debug and release mode. One difference is that I used NLog, not Serilog. I'll check if it makes any difference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants