How to resolve "The type or namespace name 'Didstopia' could not be found (are you missing a using directive or an assembly reference?)"

user2845090

I'm using VS2019 trying to build a simple .NET Standard 2.0 class library that uses the Didstopia.PDFSharp .NET Standard 2.0 nuget package.

Here's a minimal reproduction starting with my .csproj file:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Didstopia.PDFSharp" Version="1.0.0-beta8">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
  </ItemGroup>

</Project>

And here's my Class1.cs file:

using System;
using Didstopia.PDFSharp;

namespace ClassLibrary1
{
    public class Class1
    {
    }
}

When I compile I get the following message:

Class1.cs(2,7,2,16): error CS0246: The type or namespace name 'Didstopia' could not be found (are you missing a using directive or an assembly reference?)

In Visual Studio in the code editing window for Class1 the "using Didstopia.PDFSharp" line has Didstopia underlined in red.

If instead of using a package reference I use a assembly reference to the Didstopia.PDFSharp.dll, from the packages folder, the class library compiles fine.

If I fork, clone and add a Project Reference to Didstopia.PDFSharp.dll everything compiles fine.

I've done "clean", delete bin & obj folders, removed the Didstopia package from the C:\Users\[myuserid]\.nuget\packages\didstopia.pdfsharp folder innumerable times.

I'm not sure what to even try next. Is there anyway to get more information out of the compiler about why it doesn't like the package reference?

Perry Qian-MSFT

I'm not sure what to even try next. Is there anyway to get more information out of the compiler about why it doesn't like the package reference?

I think it is an issue of the nuget package Didstopia.PDFSharp 1.0.0-beta8. In my side, when l install this package in a net standard 2.0 class library project, I faced the same issue as you described and feel quite strange about it.

As a suggestion, please delete the content of <IncludeAssets> just like this:

<IncludeAssets></IncludeAssets>

This tag is about to consume the content of the nuget package and when you use it, you cannot reference the content of the dll. Pleae see this.

Besides, since this issue is more related to the package itself and it is a beta, prerelease version which may have some problems, I suggest you could contact with the author and report this issue.

Hope it could help you.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related