aspnet / RoslynCodeDomProvider

Roslyn CodeDOM provider
MIT License
84 stars 43 forks source link

CSharpCodeProvider fails on e.g. System.Linq. #147

Closed HeSitates closed 1 year ago

HeSitates commented 1 year ago

We are finally updating an old project to .Net Framework 4.8 (...)

With .Net Framework 4.7 we used Microsoft.CSharp.CSharpCodeProvider, now we are using the Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider.

But now I'm stuck several errors, e.g.:

[10-02-2023 10:16:19] [ERROR] Error during compilation:
Compiling: \GeneratedServices\Soap\bin\ROOT_TestGroep.TestSubgroep.TestService.dll
ErrorNumber: CS0234
ErrorText: The type or namespace name 'Linq' does not exist in the namespace 'System' (are you missing an assembly reference?)
Service: Bus.Service
Availability: Soap
Line: 12
Column: 18

The generated code that does not compile:

//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:4.0.30319.42000
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace Soap.TestGroep.TestSubgroep.TestService_Service {
    using System.Linq;

    public class Constants {

        public static int MaxResults = int.Parse(global::System.Configuration.ConfigurationManager.AppSettings["MaxServiceResults"]);
    }

    /*
    Rest of code deleted
    */
}

I've added extra references to Microsoft.CSharp.dll and System.Core.dll but it seems to have no impact, I'm getting the same error.

Someone has a hint?

HeSitates commented 1 year ago

After long investiggation, problem solved: