Requirements: The project needs to generate different algorithms and logic according to the customer's needs, at this time, the code may not be written dead, and some rule engine may be required to execute the customized logic.
The .NET Compiler Platform, codenamed Roslyn, is Microsoft's set of open-source compiler and code analysis APIs for the C# and Visual Basic (VB.NET) languages.
Review:
First, create a new console application with the following reference:
The code is as follows:
We compile the C# code to produce a test.exe file size only3KB。 The resulting file test.exe cannot be run as a Windows executable, and the error is reported as follows:
Unhandled Exception: System.IO.FileNotFoundException: Failed to load a file or assembly "System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e" or one of its dependencies. The system cannot find the specified file. So, execute the console application with the following commands:
After execution, the error is reported as follows:
A fatal error was encountered. The library 'hostpolicy.dll' required to execute the application was not found in 'D:\Project\ConsoleApp1\ConsoleApp1\bin\Debug\net8.0\'. Failed to run as a self-contained app. - The application was run as a self-contained app because 'D:\Project\ConsoleApp1\ConsoleApp1\bin\Debug\net8.0\test.runtimeconfig.json' was not found. - If this should be a framework-dependent app, add the 'D:\Project\ConsoleApp1\ConsoleApp1\bin\Debug\net8.0\test.runtimeconfig.json' file and specify the appropriate framework. Roughly speaking, you need a *.runtimeconfig.json file, which contains runtime information and the version of .NET Core used, reference:The hyperlink login is visible.
So, create a new test.runtimeconfig.json file with the following configuration:
Re-run the command and find that it can be executed normally, as shown in the following figure:
Reference:
The hyperlink login is visible.
The hyperlink login is visible.
The hyperlink login is visible.
|