Does .Net 4 use the built-in MarshalByRefObject methods?

I have code based on methods not on the line:

internal class MyClass : BaseClass { // should not be inlined public void DoSomething(int id) { base.Execute(id); } } public abstract class BaseClass : MarshallByRefObject { [MethodImpl(MethodImplOptions.NoInlining)] protected void Execute(params object[] args) { // does a stack walk to find signature of calling method } } 

Of course, this only works if the DoSomething method is not built-in. That is why the base class comes from MarshallByRefObject , which prevents the embedding of public methods.

This has worked so far, but I got the stack from the .Net 4 server, showing that stackwalk reached the DoSomething call.

Is .NET-inline smarter and discovers that MyClass is internal and has no chance of replacing its proxy?

+7
source share
1 answer

The comments here indicate that you also need to specify NoOptimisation to achieve what you want.

http://connect.microsoft.com/VisualStudio/feedback/details/162364/methodimpl-methodimploptions-noinlining-doesnt-work-correctly-on-x64

0
source

All Articles