0

I have a program that requires for it to read a file and compile the C# code inside of that file to an exe.

I tried using CSharpCodeProvider with CompileAssemblyFromFile because I used it in past programs but apparently it's outdated now and it gives out a 'System.PlatformNotSupportedException'. So I'm looking for alternatives and examples. Thanks in advance!

edy131109
  • 1
  • 4
  • I don't really understand roslyn so could you please provide an example? – edy131109 May 23 '23 at 19:12
  • Your original question "Why do I get a PlatformNotSupportedException exception when I use CSharpCodeProvider?" is answered by the link above. Before posting your next question, do some research into the solutions provided by that link, and be prepared to show your attempt. – gunr2171 May 23 '23 at 19:26
  • @gunr2171 None of the references show how to use Roslyn to create an application, which apparently isn't straight forward, so not very helpful. – NetMage May 23 '23 at 19:59
  • Try using the code from [this answer](https://stackoverflow.com/a/32770961/2557128) with the comment to leave off the extension so it may create an executable? – NetMage May 23 '23 at 19:59
  • @Tudeschizieuinchid because of the mention of `PlatformNotSupportedException` and being that exception documented in the [remaks of that class documentation](https://learn.microsoft.com/en-us/dotnet/api/system.codedom.compiler.codedomprovider.compileassemblyfromsource?view=windowsdesktop-5.0#remarks), looks like either .NET Core or .NET 5+ – Cleptus May 23 '23 at 21:14

0 Answers0