C# - 使用自定义配置在运行时编译c#代码


甲基蓝
2025-04-09 11:30:58 (2天前)


我有一个问题,CodeDom编译器可以使用自定义配置编译c#代码,例如x64位或x86位。默认情况下,它使用“任何CPU”配置将c#代码编译为.exe。
编译c#代码:


2 条回复
  1. 0# Hey ou | 2019-08-31 10-32



    尝试设置

    CompilerOptions

    这条路




    parameters.CompilerOptions = “-platform:anycpu32bitpreferred”;



    使用此链接中的参数




    https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-options/platform-compiler-option



    附:

    CSharpCodeProvider

    使用

    csc.exe




    https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-options/command-line-building-with-csc-exe


登录 后才能参与评论