Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I'm trying to compile a standalone C# file using the Microsoft.CSharp.CSharpCodeProvider in mscorlib version 4.

It's complaining about properties that are using expression bodies instead of statement bodies.

I.e., this it will compile:

protected Foo MyFoo
    get { return this.myFoo; }

But this it won't:

protected Foo MyFoo => this.myFoo;

Is there a more recent version of mscorlib I should be using?

Pretty sure CSharpCodeProvider is severely deprecated. You should probably look to a roslyn based solution. – Kirk Woll Dec 14, 2017 at 23:29 System.CodeDom always uses the installed version of the framework and uses the C# compiler that is stored in the framework directory (normally c:\windows\microsoft.net\framework\v4.0.30319). Just type "csc.exe" from the command line, it explicitly tells you which C# version it supports in its sign-on message. That still doesn't say anything about the version on your user's machine. But assuming you target at least 4.5 in your project, that will always be C# version 5. Feature, not a bug, you don't have to worry about deploying Roslyn to the user's machine. There is a Nuget package. – Hans Passant Dec 14, 2017 at 23:33

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.