{"id":67122,"date":"2025-05-09T09:33:35","date_gmt":"2025-05-09T01:33:35","guid":{"rendered":"https:\/\/fwq.ai\/blog\/?p=67122"},"modified":"2025-05-09T09:33:35","modified_gmt":"2025-05-09T01:33:35","slug":"%e6%8f%90%e5%8d%87c%e7%a8%8b%e5%ba%8f%e5%90%af%e5%8a%a8%e6%80%a7%e8%83%bd%e6%96%b0%e5%88%a9%e5%99%a8%ef%bc%9anativeaot%e5%9c%a8-net-9%e4%b8%ad%e7%9a%84%e5%ae%9e%e6%88%98%e9%83%a8%e7%bd%b2%e6%8c%87","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/67122\/","title":{"rendered":"\u63d0\u5347C#\u7a0b\u5e8f\u542f\u52a8\u6027\u80fd\u65b0\u5229\u5668\uff1aNativeAOT\u5728.NET 9\u4e2d\u7684\u5b9e\u6218\u90e8\u7f72\u6307\u5357"},"content":{"rendered":"<h2>\u524d\u8a00<\/h2>\n<p>\u5728\u5f53\u524d\u8f6f\u4ef6\u5f00\u53d1\u8282\u594f\u4e0d\u65ad\u52a0\u5feb\u7684\u65f6\u4ee3\uff0c\u5e94\u7528\u7a0b\u5e8f\u7684\u6027\u80fd\u6210\u4e3a\u51b3\u5b9a\u7528\u6237\u4f53\u9a8c\u4f18\u52a3\u548c\u5e02\u573a\u7ade\u4e89\u529b\u7684\u5173\u952e\u56e0\u7d20\u3002C#\u4f5c\u4e3a\u4f01\u4e1a\u7ea7\u5f00\u53d1\u4e2d\u7684\u4e3b\u529b\u8bed\u8a00\uff0c\u5176\u8fd0\u884c\u6548\u7387\u5c24\u5176\u662f\u542f\u52a8\u901f\u5ea6\u5907\u53d7\u5f00\u53d1\u8005\u5173\u6ce8\u3002\u4f20\u7edfJIT\uff08\u5373\u65f6\u7f16\u8bd1\uff09\u65b9\u5f0f\u867d\u7136\u7075\u6d3b\uff0c\u4f46\u5728\u51b7\u542f\u52a8\u573a\u666f\u4e0b\u5e38\u5e38\u663e\u5f97\u529b\u4e0d\u4ece\u5fc3\u3002\u800c\u5fae\u8f6f\u5728.NET 9\u4e2d\u5f15\u5165\u7684NativeAOT\uff08\u9884\u7f16\u8bd1\u4e3a\u672c\u5730\u673a\u5668\u7801\uff09\u6280\u672f\uff0c\u4e3aC#\u7a0b\u5e8f\u5e26\u6765\u4e86\u6027\u80fd\u7a81\u7834\uff0c\u542f\u52a8\u901f\u5ea6\u6700\u9ad8\u53ef\u63d0\u5347\u81f3\u539f\u6765\u76845\u500d\u3002<\/p>\n<p>\u672c\u6587\u5c06\u8be6\u7ec6\u89e3\u6790NativeAOT\u7684\u6838\u5fc3\u539f\u7406\u3001\u90e8\u7f72\u5b9e\u8df5\u53ca\u5176\u6027\u80fd\u8868\u73b0\uff0c\u5e76\u7ed3\u5408\u7f8e\u56fd\u670d\u52a1\u5668\u5e94\u7528\u573a\u666f\uff0c\u52a9\u529b\u5f00\u53d1\u8005\u6253\u9020\u66f4\u9ad8\u6548\u7684\u5e94\u7528\u7cfb\u7edf\u3002\u65e0\u8bba\u4f60\u662f\u4e3a\u4f01\u4e1a\u642d\u5efa\u5fae\u670d\u52a1\u96c6\u7fa4\uff0c\u8fd8\u662f\u90e8\u7f72\u9ad8\u5e76\u53d1\u5e94\u7528\uff0c\u9009\u62e9\u4e00\u6b3e\u9ad8\u6027\u80fd\u7684<strong>\u7f8e\u56fd\u4e91\u670d\u52a1\u5668<\/strong>\uff0c\u80fd\u8ba9NativeAOT\u7684\u6f5c\u529b\u6700\u5927\u5316\u91ca\u653e\u3002<\/p>\n<hr \/>\n<h2>\u4e00\u3001NativeAOT\u6280\u672f\u6982\u89c8<\/h2>\n<h3>1.1 \u4f20\u7edfJIT\u7684\u6027\u80fd\u77ed\u677f<\/h3>\n<p>\u4f20\u7edf.NET\u8fd0\u884c\u65f6\u91c7\u7528\u5373\u65f6\u7f16\u8bd1\u673a\u5236\uff0c\u5728\u7a0b\u5e8f\u542f\u52a8\u8fc7\u7a0b\u4e2d\u5c06IL\u4ee3\u7801\u8f6c\u5316\u4e3a\u673a\u5668\u7801\u3002\u8fd9\u4e00\u8fc7\u7a0b\u867d\u7136\u5728\u7075\u6d3b\u6027\u4e0a\u5177\u6709\u4f18\u52bf\uff0c\u4f46\u4f1a\u5bfc\u81f4\u660e\u663e\u7684\u542f\u52a8\u5ef6\u8fdf\u3002\u5728\u91d1\u878d\u3001\u7269\u8054\u7f51\u7b49\u5bf9\u54cd\u5e94\u65f6\u95f4\u8981\u6c42\u6781\u9ad8\u7684\u573a\u666f\u4e2d\uff0c\u8fd9\u4e00\u5ef6\u8fdf\u5c06\u5f71\u54cd\u6574\u4f53\u7cfb\u7edf\u6548\u7387\u3002<\/p>\n<p>\u4f8b\u5982\uff0c\u5728\u9ad8\u9891\u4ea4\u6613\u5e73\u53f0\u4e2d\uff0c\u6bcf\u4e00\u6b21\u4ea4\u6613\u8bf7\u6c42\u90fd\u5fc5\u987b\u7b49\u5f85\u5e94\u7528\u5b8c\u6210JIT\u7f16\u8bd1\uff0c\u54ea\u6015\u4ec5\u5ef6\u8fdf\u6570\u767e\u6beb\u79d2\uff0c\u4e5f\u53ef\u80fd\u610f\u5473\u7740\u6570\u767e\u4e07\u7f8e\u5143\u7684\u635f\u5931\u3002<\/p>\n<h3>1.2 NativeAOT\u7684\u5de5\u4f5c\u673a\u5236<\/h3>\n<p>NativeAOT\u5b8c\u5168\u98a0\u8986\u4e86JIT\u6a21\u5f0f\u7684\u8fd0\u884c\u903b\u8f91\uff0c\u5b83\u5728\u53d1\u5e03\u9636\u6bb5\u5c31\u5c06C#\u4ee3\u7801\u7f16\u8bd1\u4e3a\u539f\u751f\u53ef\u6267\u884c\u6587\u4ef6\uff0c\u542f\u52a8\u65f6\u65e0\u9700\u52a8\u6001\u7f16\u8bd1\uff0c\u7a0b\u5e8f\u53ef\u76f4\u63a5\u8fd0\u884c\u3002\u8fd9\u79cd\u673a\u5236\u5927\u5e45\u7f29\u77ed\u4e86\u542f\u52a8\u65f6\u95f4\uff0c\u5e76\u6709\u6548\u964d\u4f4e\u4e86\u5185\u5b58\u5360\u7528\uff0c\u975e\u5e38\u9002\u5408\u90e8\u7f72\u5728\u8d44\u6e90\u6709\u9650\u7684<strong>\u7f8e\u56fdVPS<\/strong>\u4e0a\uff0c\u5e2e\u52a9\u4f01\u4e1a\u4ee5\u66f4\u4f4e\u6210\u672c\u83b7\u5f97\u66f4\u9ad8\u6027\u80fd\u3002<\/p>\n<h3>1.3 \u4f18\u52bf\u6c47\u603b<\/h3>\n<ul>\n<li><strong>\u542f\u52a8\u901f\u5ea6\u5feb<\/strong>\uff1a\u6d4b\u8bd5\u6570\u636e\u663e\u793a\uff0c\u7a0b\u5e8f\u542f\u52a8\u65f6\u95f4\u5e73\u5747\u63d0\u53474-6\u500d\u3002<\/li>\n<li><strong>\u5185\u5b58\u4f7f\u7528\u66f4\u4f18<\/strong>\uff1a\u65e0\u9700\u8fd0\u884c\u65f6JIT\u5185\u5b58\u5206\u914d\uff0c\u9002\u914d\u5d4c\u5165\u5f0f\u6216\u4e91\u539f\u751f\u73af\u5883\u3002<\/li>\n<li><strong>\u6027\u80fd\u66f4\u7a33\u5b9a<\/strong>\uff1a\u7f16\u8bd1\u671f\u95f4\u5373\u5b8c\u6210\u4f18\u5316\uff0c\u907f\u514d\u8fd0\u884c\u65f6\u6027\u80fd\u6ce2\u52a8\u3002<\/li>\n<\/ul>\n<hr \/>\n<h2>\u4e8c\u3001.NET 9\u4e2dNativeAOT\u90e8\u7f72\u5b9e\u6218<\/h2>\n<h3>2.1 \u73af\u5883\u51c6\u5907<\/h3>\n<ul>\n<li>\u5b89\u88c5.NET 9 SDK\uff08\u53ef\u4ece\u5fae\u8f6f\u5b98\u7f51\u83b7\u53d6\uff09<\/li>\n<li>\u5b89\u88c5\u5fc5\u8981\u7684C++\u7f16\u8bd1\u73af\u5883\uff1a\n<ul>\n<li>Windows\uff1a\u5efa\u8bae\u4f7f\u7528Visual Studio 2022\u5e76\u542f\u7528C++\u684c\u9762\u5f00\u53d1<\/li>\n<li>Ubuntu\uff1a\u6267\u884c <code>sudo apt-get install clang zlib1g-dev<\/code><\/li>\n<li>macOS\uff1a\u6267\u884c <code>xcode-select --install<\/code><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h3>2.2 \u521b\u5efa\u5e76\u914d\u7f6e\u9879\u76ee<\/h3>\n<p>\u4f7f\u7528\u547d\u4ee4\u884c\u5de5\u5177\u5feb\u901f\u521d\u59cb\u5316\u9879\u76ee\uff1a<\/p>\n<pre><code class=\"language-bash\">dotnet new console -n NativeAOTDemo\r\n<\/code><\/pre>\n<p>\u4fee\u6539<code>.csproj<\/code>\u6587\u4ef6\uff0c\u542f\u7528NativeAOT\uff1a<\/p>\n<pre><code class=\"language-xml\">&lt;PropertyGroup&gt;\r\n  &lt;PublishAot&gt;true&lt;\/PublishAot&gt;\r\n&lt;\/PropertyGroup&gt;\r\n<\/code><\/pre>\n<h3>2.3 \u4ee3\u7801\u8c03\u6574\u6ce8\u610f\u4e8b\u9879<\/h3>\n<p>\u7531\u4e8eNativeAOT\u5728\u8fd0\u884c\u524d\u5df2\u5b8c\u6210\u6240\u6709\u7f16\u8bd1\uff0c\u56e0\u6b64\u4e0d\u652f\u6301\u67d0\u4e9b\u52a8\u6001\u53cd\u5c04\u884c\u4e3a\u3002\u5f00\u53d1\u8005\u5e94\u907f\u514d\u5982\u4e0b\u4ee3\u7801\uff1a<\/p>\n<pre><code class=\"language-csharp\">Type type = Type.GetType(\"MyNamespace.MyClass\");\r\n<\/code><\/pre>\n<p>\u6539\u4e3a\u5728\u914d\u7f6e\u6587\u4ef6\u4e2d\u5b9a\u4e49\u7c7b\u578b\uff0c\u5e76\u8fdb\u884c\u9759\u6001\u52a0\u8f7d\u3002<\/p>\n<p>\u5982\u679c\u4f7f\u7528\u4f9d\u8d56\u6ce8\u5165\u5bb9\u5668\uff0c\u5efa\u8bae\u663e\u5f0f\u6ce8\u518c\u670d\u52a1\u7c7b\u578b\u800c\u975e\u52a8\u6001\u6ce8\u518c\uff1a<\/p>\n<pre><code class=\"language-csharp\">builder.RegisterType&lt;MyService&gt;().As&lt;IMyService&gt;();\r\n<\/code><\/pre>\n<h3>2.4 \u53d1\u5e03\u5e94\u7528<\/h3>\n<p>\u4ee5\u53d1\u5e03\u5230Windows\u5e73\u53f0\u4e3a\u4f8b\uff1a<\/p>\n<pre><code class=\"language-bash\">dotnet publish -r win-x64 -c Release\r\n<\/code><\/pre>\n<p>\u6216\u8005Linux ARM64\u67b6\u6784\uff1a<\/p>\n<pre><code class=\"language-bash\">dotnet publish -r linux-arm64 -c Release\r\n<\/code><\/pre>\n<p>\u53ef\u5728Visual Studio\u4e2d\u9009\u62e9\u201c\u53d1\u5e03\u5230\u6587\u4ef6\u5939\u201d\u5e76\u8bbe\u7f6e\u4e3a\u201c\u672c\u5730\u53d1\u5e03\u201d\uff0c\u4e00\u952e\u751f\u6210NativeAOT\u7a0b\u5e8f\u3002<\/p>\n<hr \/>\n<h2>\u4e09\u3001NativeAOT\u6027\u80fd\u6d4b\u8bd5<\/h2>\n<p>\u901a\u8fc7<code>Stopwatch<\/code>\u5de5\u5177\u9a8c\u8bc1NativeAOT\u4f18\u5316\u6548\u679c\uff1a<\/p>\n<pre><code class=\"language-csharp\">var sw = Stopwatch.StartNew();\r\n\/\/ \u5e94\u7528\u4e3b\u903b\u8f91\r\nsw.Stop();\r\nConsole.WriteLine($\"\u542f\u52a8\u8017\u65f6\uff1a{sw.ElapsedMilliseconds}ms\");\r\n<\/code><\/pre>\n<p>\u6d4b\u8bd5\u7ed3\u679c\u663e\u793a\uff0c\u5728\u76f8\u540c\u786c\u4ef6\u73af\u5883\u4e0b\uff0cNativeAOT\u5e94\u7528\u7684\u542f\u52a8\u901f\u5ea6\u6bd4\u4f20\u7edfJIT\u7248\u672c\u5feb\u4e865\u500d\u4ee5\u4e0a\u3002\u5c24\u5176\u5728\u642d\u914d<strong>\u7f8e\u56fd\u72ec\u7acb\u670d\u52a1\u5668<\/strong>\u90e8\u7f72\u5927\u578bWeb\u7cfb\u7edf\u65f6\uff0cNativeAOT\u5c55\u73b0\u51fa\u5353\u8d8a\u7684\u6027\u80fd\u8868\u73b0\u548c\u8d44\u6e90\u8c03\u5ea6\u4f18\u52bf\u3002<\/p>\n<hr \/>\n<h2>\u56db\u3001\u603b\u7ed3\u4e0e\u90e8\u7f72\u5efa\u8bae<\/h2>\n<p>NativeAOT\u4e3a.NET\u5e73\u53f0\u6ce8\u5165\u4e86\u65b0\u7684\u6027\u80fd\u6d3b\u529b\uff0c\u5c24\u5176\u5728\u542f\u52a8\u901f\u5ea6\u4e0e\u5185\u5b58\u6548\u7387\u65b9\u9762\u7684\u63d0\u5347\uff0c\u4e3a\u9ad8\u8d1f\u8f7d\u670d\u52a1\u63d0\u4f9b\u4e86\u53ef\u9760\u652f\u6491\u3002\u5bf9\u4e8e\u8fd0\u884c\u5728\u4e91\u8ba1\u7b97\u73af\u5883\u4e2d\u7684\u5fae\u670d\u52a1\u67b6\u6784\u3001\u5bb9\u5668\u5316\u90e8\u7f72\u3001IoT\u7cfb\u7edf\uff0cNativeAOT\u65e0\u7591\u662f\u63d0\u5347\u7cfb\u7edf\u54cd\u5e94\u4e0e\u8282\u7701\u8d44\u6e90\u7684\u91cd\u8981\u9009\u62e9\u3002<\/p>\n<p>\u5728\u90e8\u7f72\u8fd9\u4e9b\u5173\u952e\u7cfb\u7edf\u65f6\uff0c\u9009\u62e9\u4e00\u6b3e\u6027\u80fd\u7a33\u5b9a\u3001\u7f51\u7edc\u901a\u7545\u7684<strong>\u7f8e\u56fd\u670d\u52a1\u5668<\/strong>\u81f3\u5173\u91cd\u8981\u3002\u63a8\u8350\u4f7f\u7528<a href=\"https:\/\/fwq.ai\/\">\u7f8e\u56fdVPS<\/a>\u4e0e<a href=\"https:\/\/fwq.ai\/\">\u72ec\u7acb\u670d\u52a1\u5668<\/a>\u4ea7\u54c1\uff0c\u52a9\u529b\u5f00\u53d1\u8005\u4ee5\u6781\u5177\u6027\u4ef7\u6bd4\u7684\u65b9\u5f0f\u5b9e\u73b0\u9ad8\u6027\u80fd\u90e8\u7f72\u9700\u6c42\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u8a00 \u5728\u5f53\u524d\u8f6f\u4ef6\u5f00\u53d1\u8282\u594f\u4e0d\u65ad\u52a0\u5feb\u7684\u65f6\u4ee3\uff0c\u5e94\u7528\u7a0b\u5e8f\u7684\u6027\u80fd\u6210\u4e3a\u51b3\u5b9a\u7528\u6237\u4f53\u9a8c\u4f18\u52a3\u548c\u5e02\u573a\u7ade\u4e89\u529b\u7684\u5173\u952e\u56e0\u7d20\u3002C#\u4f5c\u4e3a\u4f01\u4e1a\u7ea7\u5f00\u53d1\u4e2d\u7684\u4e3b\u529b\u8bed\u8a00\uff0c\u5176\u8fd0\u884c\u6548\u7387\u5c24\u5176\u662f\u542f\u52a8\u901f\u5ea6\u5907\u53d7\u5f00\u53d1\u8005\u5173\u6ce8\u3002\u4f20\u7edfJIT\uff08\u5373\u65f6\u7f16\u8bd1\uff09\u65b9\u5f0f\u867d\u7136\u7075\u6d3b\uff0c\u4f46\u5728\u51b7\u542f\u52a8\u573a\u666f\u4e0b\u5e38\u5e38\u663e\u5f97\u529b\u4e0d\u4ece\u5fc3\u3002\u800c\u5fae\u8f6f\u5728.NET 9\u4e2d\u5f15\u5165\u7684NativeAOT\uff08\u9884\u7f16\u8bd1\u4e3a\u672c\u5730\u673a\u5668\u7801\uff09\u6280\u672f\uff0c\u4e3aC#\u7a0b\u5e8f\u5e26\u6765\u4e86\u6027\u80fd\u7a81\u7834\uff0c\u542f\u52a8\u901f\u5ea6\u6700\u9ad8\u53ef\u63d0\u5347\u81f3\u539f\u6765\u76845\u500d\u3002 \u672c\u6587\u5c06\u8be6\u7ec6\u89e3\u6790NativeAOT\u7684\u6838\u5fc3\u539f\u7406\u3001\u90e8\u7f72\u5b9e\u8df5\u53ca\u5176\u6027\u80fd\u8868\u73b0\uff0c\u5e76\u7ed3\u5408\u7f8e\u56fd\u670d\u52a1\u5668\u5e94\u7528\u573a\u666f\uff0c\u52a9\u529b\u5f00\u53d1\u8005\u6253\u9020\u66f4\u9ad8\u6548\u7684\u5e94\u7528\u7cfb\u7edf\u3002\u65e0\u8bba\u4f60\u662f\u4e3a\u4f01\u4e1a\u642d\u5efa\u5fae\u670d\u52a1\u96c6\u7fa4\uff0c\u8fd8\u662f\u90e8\u7f72\u9ad8\u5e76\u53d1\u5e94\u7528\uff0c\u9009\u62e9\u4e00\u6b3e\u9ad8\u6027\u80fd\u7684\u7f8e\u56fd\u4e91\u670d\u52a1\u5668\uff0c\u80fd\u8ba9NativeAOT\u7684\u6f5c\u529b\u6700\u5927\u5316\u91ca\u653e\u3002 \u4e00\u3001NativeAOT\u6280\u672f\u6982\u89c8 1.1 \u4f20\u7edfJIT\u7684\u6027\u80fd\u77ed\u677f \u4f20\u7edf.NET\u8fd0\u884c\u65f6\u91c7\u7528\u5373\u65f6\u7f16\u8bd1\u673a\u5236\uff0c\u5728\u7a0b\u5e8f\u542f\u52a8\u8fc7\u7a0b\u4e2d\u5c06IL\u4ee3\u7801\u8f6c\u5316\u4e3a\u673a\u5668\u7801\u3002\u8fd9\u4e00\u8fc7\u7a0b\u867d\u7136\u5728\u7075\u6d3b\u6027\u4e0a\u5177\u6709\u4f18\u52bf\uff0c\u4f46\u4f1a\u5bfc\u81f4\u660e\u663e\u7684\u542f\u52a8\u5ef6\u8fdf\u3002\u5728\u91d1\u878d\u3001\u7269\u8054\u7f51\u7b49\u5bf9\u54cd\u5e94\u65f6\u95f4\u8981\u6c42\u6781\u9ad8\u7684\u573a\u666f\u4e2d\uff0c\u8fd9\u4e00\u5ef6\u8fdf\u5c06\u5f71\u54cd\u6574\u4f53\u7cfb\u7edf\u6548\u7387\u3002 \u4f8b\u5982\uff0c\u5728\u9ad8\u9891\u4ea4\u6613\u5e73\u53f0\u4e2d\uff0c\u6bcf\u4e00\u6b21\u4ea4\u6613\u8bf7\u6c42\u90fd\u5fc5\u987b\u7b49\u5f85\u5e94\u7528\u5b8c\u6210JIT\u7f16\u8bd1\uff0c\u54ea\u6015\u4ec5\u5ef6\u8fdf\u6570\u767e\u6beb\u79d2\uff0c\u4e5f\u53ef\u80fd\u610f\u5473\u7740\u6570\u767e\u4e07\u7f8e\u5143\u7684\u635f\u5931\u3002 1.2 NativeAOT\u7684\u5de5\u4f5c\u673a\u5236 NativeAOT\u5b8c\u5168\u98a0\u8986\u4e86JIT\u6a21\u5f0f\u7684\u8fd0\u884c\u903b\u8f91\uff0c\u5b83\u5728\u53d1\u5e03\u9636\u6bb5\u5c31\u5c06C#\u4ee3\u7801\u7f16\u8bd1\u4e3a\u539f\u751f\u53ef\u6267\u884c\u6587\u4ef6\uff0c\u542f\u52a8\u65f6\u65e0\u9700\u52a8\u6001\u7f16\u8bd1\uff0c\u7a0b\u5e8f\u53ef\u76f4\u63a5\u8fd0\u884c\u3002\u8fd9\u79cd\u673a\u5236\u5927\u5e45\u7f29\u77ed\u4e86\u542f\u52a8\u65f6\u95f4\uff0c\u5e76\u6709\u6548\u964d\u4f4e\u4e86\u5185\u5b58\u5360\u7528\uff0c\u975e\u5e38\u9002\u5408\u90e8\u7f72\u5728\u8d44\u6e90\u6709\u9650\u7684\u7f8e\u56fdVPS\u4e0a\uff0c\u5e2e\u52a9\u4f01\u4e1a\u4ee5\u66f4\u4f4e\u6210\u672c\u83b7\u5f97\u66f4\u9ad8\u6027\u80fd\u3002 1.3 \u4f18\u52bf\u6c47\u603b \u542f\u52a8\u901f\u5ea6\u5feb\uff1a\u6d4b\u8bd5\u6570\u636e\u663e\u793a\uff0c\u7a0b\u5e8f\u542f\u52a8\u65f6\u95f4\u5e73\u5747\u63d0\u53474-6\u500d\u3002 \u5185\u5b58\u4f7f\u7528\u66f4\u4f18\uff1a\u65e0\u9700\u8fd0\u884c\u65f6JIT\u5185\u5b58\u5206\u914d\uff0c\u9002\u914d\u5d4c\u5165\u5f0f\u6216\u4e91\u539f\u751f\u73af\u5883\u3002 \u6027\u80fd\u66f4\u7a33\u5b9a\uff1a\u7f16\u8bd1\u671f\u95f4\u5373\u5b8c\u6210\u4f18\u5316\uff0c\u907f\u514d\u8fd0\u884c\u65f6\u6027\u80fd\u6ce2\u52a8\u3002 \u4e8c\u3001.NET 9\u4e2dNativeAOT\u90e8\u7f72\u5b9e\u6218 2.1 \u73af\u5883\u51c6\u5907 \u5b89\u88c5.NET 9 SDK\uff08\u53ef\u4ece\u5fae\u8f6f\u5b98\u7f51\u83b7\u53d6\uff09 \u5b89\u88c5\u5fc5\u8981\u7684C++\u7f16\u8bd1\u73af\u5883\uff1a Windows\uff1a\u5efa\u8bae\u4f7f\u7528Visual Studio 2022\u5e76\u542f\u7528C++\u684c\u9762\u5f00\u53d1 Ubuntu\uff1a\u6267\u884c sudo apt-get install clang zlib1g-dev macOS\uff1a\u6267\u884c xcode-select &#8211;install 2.2 \u521b\u5efa\u5e76\u914d\u7f6e\u9879\u76ee \u4f7f\u7528\u547d\u4ee4\u884c\u5de5\u5177\u5feb\u901f\u521d\u59cb\u5316\u9879\u76ee\uff1a dotnet new console -n NativeAOTDemo \u4fee\u6539.csproj\u6587\u4ef6\uff0c\u542f\u7528NativeAOT\uff1a &lt;PropertyGroup&gt; &lt;PublishAot&gt;true&lt;\/PublishAot&gt; &lt;\/PropertyGroup&gt; 2.3 \u4ee3\u7801\u8c03\u6574\u6ce8\u610f\u4e8b\u9879 \u7531\u4e8eNativeAOT\u5728\u8fd0\u884c\u524d\u5df2\u5b8c\u6210\u6240\u6709\u7f16\u8bd1\uff0c\u56e0\u6b64\u4e0d\u652f\u6301\u67d0\u4e9b\u52a8\u6001\u53cd\u5c04\u884c\u4e3a\u3002\u5f00\u53d1\u8005\u5e94\u907f\u514d\u5982\u4e0b\u4ee3\u7801\uff1a Type type = [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[],"class_list":["post-67122","post","type-post","status-publish","format-standard","hentry","category-coding"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/67122","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=67122"}],"version-history":[{"count":1,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/67122\/revisions"}],"predecessor-version":[{"id":67124,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/67122\/revisions\/67124"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=67122"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=67122"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=67122"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}