Can you compile C# so it doesn't need the .NET Framework at runtime?

前端 未结 8 1257
暖寄归人
暖寄归人 2020-11-28 08:53

Is it possible to force the C# compiler to pull all the referenced calls out of the framework and pack them into dlls or even a single executable?

I like writing qu

相关标签:
8条回答
  • 2020-11-28 09:21

    It is now possible to compile C# to native code using Microsoft .NET Native: https://msdn.microsoft.com/en-us/library/dn584397(v=vs.110).aspx

    It automatically compiles the release version of apps that are written in managed code (C# or Visual Basic) and that target the .NET Framework and Windows 10 to native code.

    ...

    For users of your apps, .NET Native offers these advantages:

    •Fast execution times

    •Consistently speedy startup times

    •Low deployment and update costs

    •Optimized app memory usage

    This only works with Visual Studio .NET 2015.

    0 讨论(0)
  • 2020-11-28 09:33

    This dependency which unfortunately frequently breaks or is missing in the real world is a big reason why C# has not had a wider adoption. On the flip side most development does have dependencies.. look at C++ & Java for example.

    I don't think we will really get away from these dependency issues anytime soon, so I recommend that if you want to use C#, that you make a wrapper for installation which checks for the .net framework version dependency you need, and if missing notify the user that they need this to run your app.

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