Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7696527
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T21:48:00+00:00 2026-05-31T21:48:00+00:00

I’m currently working on a compiler for a language (an external byte-code), and am

  • 0

I’m currently working on a compiler for a language (an external byte-code), and am using System.Reflection.Emit.

Now, everything looks fine when I open the generated assembly in reflector, and it re-compiles as C# just fine as well (and runs), but when I try to run the main function which gets generated, I get an InvalidProgramException:

“Common Language Runtime detected an invalid program.”

It is probably just a single op-code that is causing the issue, but, because that main function uses 100+ op-codes, I can’t determine which op-code is causing the issue.

Each op-code is very involved, so manually testing every op-code is a no-go.

Is there a way to get .NET to tell me where in the function it’s detecting an invalid program?

And if not, is there some other tool I can use to determine the source of the issue?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T21:48:01+00:00Added an answer on May 31, 2026 at 9:48 pm

    I’d better write this up as an answer. You can use the PEVerify tool to perform assembly validation. It is part of the Windows SDK tools, best way to run it is from the Visual Studio Command Prompt, peverify.exe command. You’ll want to run it with the /il command line option to check the IL you generated, /md to verify the assembly metadata.

    You’ll get a better diagnostic from this tool, the runtime exception that the jitter generates is a bit too uninformative to pinpoint the exact mistake. I cannot vouch that it performs the exact same checks as the jitter, these are distinct chunks of code and the jitter has a bit of an edge over static analysis. The tool was however specifically designed for your use case, people that write IL generators. I’ll just quote the promises made in the MSDN article:

    Peverify.exe performs comprehensive MSIL verification checks based on dataflow analysis plus a list of several hundred rules on valid metadata. For detailed information on the checks Peverify.exe performs, see the “Metadata Validation Specification” and the “MSIL Instruction Set Specification” in the Tools Developers Guide folder in the Windows Software Development Kit (SDK).

    Turns out it worked well for you, that’s cool 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working with an upstream system that sometimes sends me text destined for HTML/XML
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I am reading a book about Javascript and jQuery and using one of the
I want use html5's new tag to play a wav file (currently only supported
I would like to run a str_replace or preg_replace which looks for certain words
I have this code to decode numeric html entities to the UTF8 equivalent character.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.