Compiling C# to Native?

后端 未结 11 1342
醉酒成梦
醉酒成梦 2020-12-12 10:26

I think I\'m somewhat confused about compiling .NET byte-code to native code, or maybe I\'m confused about the end result. So please bear with me as I try to sort through w

相关标签:
11条回答
  • 2020-12-12 11:15

    Spoon (previously Xenocode) has a product that might fit your needs. We use it for a WPF based installer UI so we don't have to bootstrap .net in order to load the setup program itself.

    0 讨论(0)
  • 2020-12-12 11:21

    Other answers mention Microsoft's .NET Native compiler but do not tell you how to do that.

    Here is a tutorial using CoreRT on how to compile your C# project to native code.

    Note: I also had to comment out the following line for everything to work:

    <!-- <add key="helloworld" value="https://api.helloworld.org/v3/index.json" /> -->
    

    The output is a roughly 4MB sized executable:

    Indeed, the code is no longer readable with .NET decompilers and IDA Pro (a native code disassembler) recognizes it as native code.

    0 讨论(0)
  • 2020-12-12 11:25

    NGEN adds native code, but it does not remove the MSIL. Therefore, any tool operating on the MSIL can still work. You also need this for reflection, something that would be very hard for a true native compiler.

    0 讨论(0)
  • 2020-12-12 11:26

    I just validated .Net Native on VS2015 & Windows 8.1 (when configured correctly, examine .proj to validate) and building for a particular architecture (may be overkill, haven't validated), will produce a native file which will give you the "harder to reverse engineer" code you are looking for which for me was unabled to read .dll via DotPeek(free .Net decompiler from JetBrains).

    0 讨论(0)
  • 2020-12-12 11:29

    Yesterday, at Build 2014, Microsoft announced .NET Native. According to the FAQ, "... Initially, we are focusing on Windows Store apps with .NET Native. In the longer term we will continue to improve native compilation for all .NET applications."

    0 讨论(0)
提交回复
热议问题