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 9321141
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T03:47:43+00:00 2026-06-19T03:47:43+00:00

As explained in another question , Ngen is usually only allowed to inline methods

  • 0

As explained in another question, Ngen is usually only allowed to inline methods across assemblies if the method has the TargetedPatchingOptOutAttribute set.

But is this also true for hard bound assemblies by using the DependencyAttribute with LoadHint.Always?

edit: Maybe the answer to my initial question is no, otherwise it would make no sense that the TargetedPatchingOptOutAttribute is used in mscorlib since this assembly is always hard bound (it has the DefaultDependencyAttribute set). So I’d like to rephrase my question: Is the TargetedPatchingOptOutAttribute the only way to get a method inlined across native images of assemblies?

  • 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-06-19T03:47:44+00:00Added an answer on June 19, 2026 at 3:47 am

    TLDR version: Don’t care about the TargetedPatchingOptOutAttribute, it should only be used in the .NET Framework assemblies. Method inlining of self developed assemblies works the same with Ngen and JIT.


    It seems like that other question led me to a completely wrong assumption. Methods in our own assemblies are inlined across native image boundries, even if they are neither hard bound nor have the TargetedPatchingOptOutAttribute set. This attribute only affects the .NET Framework assemblies.

    A Microsoft blog post has a quite good section about the TargetedPatchingOptOutAttribute:

    "Targeted Patching – Method lacks TargetedPatchingOptOutAttribute" –
    this relates to a new feature in CLR 4 where NGEN images are more
    version resilient. In a nutshell, we hope to be able to apply a patch
    or fix to mscorlib.dll and not have to recompile all the other native
    images on the machine that depend upon it. This should only apply to
    methods in the .NET framework class libraries because they are the
    only assemblies that can opt into this feature.

    This means: Because .NET Framework assemblies now support targeted patching in .NET 4.0, methods from those assemblies usually can’t be inlined. But methods that are marked with the TargetedPatchingOptOutAttribute are performance critical and therefore opt out of the targeted patching (which means if they are ever changed, all native images that use that method need to be recompiled). Since our own assemblis don’t use targeted patching, there is no reason to prevent method inlining across native images.

    To test this I created a small sample that shows the call stack of an exception thrown in a different assembly. Only my main method and the method that throwed the exception were in the call stack. Some other small methods placed in both the calling and called assembly (that do basically nothing more than calling the next method) were not in the call stack. This behavior didn’t change after creating native images for the assemblies (yes, I checked that the native images were used).

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

Sidebar

Related Questions

Can anyone explain me the difference of all and also an another question does
Found this question that explained a way to communicate between layers. However there is
This popular Stack Overflow question explained why CSS selectors are parsed right to left.
To begin with, let me apologise for asking yet another question referring this topic.
Hi I'm back with another question,I have started using EF and I'm having problem
Note: This question was spawned from another question I had regarding the use of
I recently started this question in another thread (to which Reed Copsey graciously responded)
I sort of asked this question at the end of another post but feel
I'll try to explain this better on another question. This is the query that
Thank you to Yuji for answering another question I had and pointing me to

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.