This project is read-only.

'Microsoft.CodeAnalysis.MetadataFileReference' is inaccessible due to its protection level

Topics: APIs, General
Nov 17, 2014 at 12:22 AM

I am trying to get a semantic model for a syntax tree as suggested in the document in the following way:
var compilation = CSharpCompilation.Create("HelloWorld") .AddReferences( new MetadataFileReference( typeof(object).Assembly.Location)) .AddSyntaxTrees(tree);
but then I get the error that 'Microsoft.CodeAnalysis.MetadataFileReference' is inaccessible due to its protection level. Any hint why this is happening?

Nov 17, 2014 at 1:14 AM
I found the answer by myself:

references: new[] { MetadataReference.CreateFromAssembly(typeof(object).Assembly) }
Marked as answer by TomasMatousek on 12/14/2014 at 5:15 PM
Nov 23, 2014 at 5:39 PM

I just wanted to thank you. I encountered this and it solved the problem.

MSFT folks, I did NOT find this via normal searches. I found it because I have the digest in my Outlook and I was searching Outlook. It's kind of late for a breaking change to be hard to find. Wherever else it is, I didn't run across it.