Ignore compiler error BC30668: ‘Types with embedded references are not supported in this version of your compiler’

  Uncategorised

I’m using Visual Studio 2019 v16.8.2, and when I try to compile a code written in VB.NET on which I declared a function whose parameter with name "ImageData" is a class from a 3rd party library written in C#, and that "ImageData" class expose a public property of type System.Span, I get the next compiler error:

Error BC30668 ‘ImageData’ is obsolete:
‘Types with embedded references are not supported in this version of your compiler.’.

After a little research it seems this is a non-sense decision by design:

They have confirmed that this behavior is by design. I don’t understand
why they are not intend to let stack-only structures consumable in VB
when c# is able to define them. Maybe they thought ref structs are
similar to unsafe types. So, in most cases, VB developers may not
hurry to consume these types. But this assumption does not make sense,
because ref structs are not unsafe codes. They can be defined or be
used in C# 7.2 outside of the unsafe context, why can’t we just
consume them in VB?

Both System.Span(Of T) and System.ReadOnlySpan(Of T) are important new
APIs for .NET developers who care about both performance and type
safety. We should feel natural when using them, rather than seeing the
annoying BC30668 compilation error.

Is there any workaround to ignore this compiler error so I can compile my code under VBNET?.

Source: Visual Studio Questions

LEAVE A COMMENT