Did you ever wondered what it would be like if you are not limited to static Main(string[] args) as your entrypoint? Did you ever wanted more freedom over where your app starts? Actually you can have that.1b74agBut in order to do it – you need to go one level lower. Into an IL level. In the last post from this series – you got some knowledge about basic tooling. Here we will see how to make something with them.

If you decompile your app to IL you will notice that on the Main method there’s a directive .entrypoint. This what specifies where the app will start. It is placed automatically by the C# compiler. But if we can – we can move it.

screen-shot-2016-09-24-at-18-50-31

Just remove it and paste it in any other static method. Compile (ILASM) & run. It works like a charm. If you try to do the same with non-static method – you will get an error during ilasm-ing your code.

This is a nice little trick that can use on your .NET guru friends to check their knowledge. Have fun.