问题
I am trying to compile a simple code in C# using Microsoft.CodeAnalysis.CSharp.
The problem is in trying to add the reference to mscorlib.dll. As the CreateFromAssembly method of the MetadataReference class is deprecated I am trying to use the CreateFromFile method (as suggested):
var mscorlibAssembly = Assembly.Load(new AssemblyName("mscorlib.dll")).ManifestModule.Assembly;
var mscorlibref = MetadataReference.CreateFromFile(mscorlibAssembly.Location);
result.Add(mscorlibref);
The Location property of the assembly returns "mscorlib.dll" and not the full path causing the error: System.IO.FileNotFoundException: Could not find file "/mscorlib.dll"
How can I load the correct MSCorLib reference to be able to use CSharpCompilation?
来源:https://stackoverflow.com/questions/51025921/xamarin-android-runtime-c-sharp-compilation