Roslyn: Error CS0030 Cannot convert type 'object' to 'System.TypedReference'

Created on 19 Dec 2017  路  5Comments  路  Source: dotnet/roslyn

I can't compile the following code with latest version VS 2017 build 15.5.0.

 void MyMethod(object[] objects)
{
TypedReference.SetTypedReference((TypedReference)objects[0], objects[1]);
}

_This issue has been moved from https://developercommunity.visualstudio.com/content/problem/166353/error-cs0030-cannot-convert-type-object-to-systemt.html
VSTS ticketId: 537144_
_These are the original issue comments:_
(no comments)
_These are the original issue solutions:_
(no solutions)

Area-Compilers Developer Community

Most helpful comment

Tagging @VSadov to triage and advise. Thanks

All 5 comments

Tagging @VSadov to triage and advise. Thanks

When will this bug be resolved?

This is not a bug. A TypedReference cannot be boxed, so there is no conversion between object and TypedReference in either direction. That is why you cannot cast objects[0] to the type TypedReference.

I don't have problem with older compiler version.

@bprg Old compiler has bugs in this area. It may permit code that would not run or even be accepted by the JIT.

Was this page helpful?
0 / 5 - 0 ratings