I'm trying to convert a PCL to .NET Standard 1.3 and failing. I've narrowed the failure down to a really simple example that I can't understand why it's failing.
I have a class that implements IMarkupExtension
and simply compiling a project with just that class fails with:
The type 'IServiceProvider' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.ComponentModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
Why on earth is it trying to pull in System.ComponentModel
for a Xamarin Forms library that's using .NET Standard? It makes no sense to me.
The project references are as simple as you can get:
The class implementation couldn't be any simpler:
namespace OpenNETCF
{
public sealed class ScaledDouble : IMarkupExtension
{
public object ProvideValue(IServiceProvider serviceProvider)
{
return null;
}
}
}
I can get rid of the compiler error by manually editing the project file to include System.ComponentModel
, but unsurprisingly the consuming app fails to load the type at runtime.
<ItemGroup>
<PackageReference Include="Xamarin.Forms" Version="2.3.4.267" />
<!-- Required for IMarkupExtension and IServiceProvider to compile. No idea why. -->
<PackageReference Include="System.ComponentModel" Version="4.3.0" />
</ItemGroup>
What's going on here??
.NET Standard projects doesn't have default assemblies. You should add reference or download from nuget.
PM> Install-Package System.ComponentModel
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With