-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Closed
Description
I'm using Roslyn to compile my class in runtime to assembly
output. I've added my needed assemblies into metadata references as below:
string p = Path.GetDirectoryName(typeof(object).Assembly.Location);
_ref = new MetadataReference[] {
MetadataReference.CreateFromFile(Path.Combine(p, "System.Collections.dll")),
MetadataReference.CreateFromFile(Path.Combine(p, "System.Runtime.dll")),
MetadataReference.CreateFromFile(Path.Combine(p, "System.Private.CoreLib.dll")),
MetadataReference.CreateFromFile(typeof(object).Assembly.Location),
MetadataReference.CreateFromFile(typeof(Schema).Assembly.Location)
};
And my CSharp syntax tree:
using System;
namespace _
{
public sealed class Model : Record
{
public string name;
public decimal amount;
public bool granted;
public DateTime birthdate;
}
}
And when I use my dll
file in another project, I got an error when I create an instance of Model
, the error is located on my decimal
property which is amount
. Omnisharp shows me:
The type 'Decimal' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'.
As far as I known, the System.Private.CoreLib.dll
has been existed in typeof(object).Assembly.Location
, so it doesn't make any sense if still giving me the error.
What's wrong here??
Metadata
Metadata
Assignees
Labels
No labels