Migration to netstandard2.0 - CS0246: 'ExportAttribute' could not be found

34 Views Asked by At

When I try to migrate to the <TargetFramework>netstandard2.0</TargetFramework>

I have error error CS0246: The type or namespace name 'ExportAttribute' could not be found (are you missing a using directive or an assembly reference?)

here

 [Export( typeof( IViewModelRepositoryFactory ) )]
internal sealed class ViewModelRepositoryFactory : IViewModelRepositoryFactory
{
    private readonly IViewModelFactory[] _viewModelFactories;

    [ImportingConstructor]
    public ViewModelRepositoryFactory( [ImportMany] IViewModelFactory[] viewModelFactories )

How to fix it - looks like I need some nuget package ?

Inside what nuget I can found netstandard2.0 version for ExportAttribute ?

1

There are 1 best solutions below

0
On

Just use latest System.ComponentModel.Composition nuget package

for example add this to your csproj file

  <ItemGroup>
  <PackageReference Include="System.ComponentModel.Composition" Version="4.7.0" />