1

I have just started exploring NuGet in Visual Studio so this is pretty much a beginner question. I am trying to understand if name of a NuGet package as it appears in Solution Explorer is always the thing what we include in using clause? Here is the context. I am using Visual Studio 2019. I created a stub project (Console Application) in my solution which targets .NET 5.0 framework. Here is the stub:-

using System;

namespace Random
{
    class Program
    {
        static void Main(string[] args)
        {
           
        }
    }
}

Now , I installed NuGet package against the project called itext7 7.1.15 (project url https://itextpdf.com/) using 'Manage NuGet Packages' option from Solution Explorer. The package installation succeeded.

enter image description here

As you can see in the screenshot , the name of the package appeaes as 'itext7' , so I included it in my code as shown in the following screenshot but as you can see it's not being recognized:-

enter image description here

My actual question is -- say if I just install any NuGet package randomly , is name of the package as I see it in Solution Explorer not enough knowledge in order to issue using statement against that package? In many other packages that I tried this worked. So how does one know exactly what to be used for using for an arbitrary package?

Dhiraj
  • 3,396
  • 4
  • 41
  • 80
  • As far as I know, no mandatory rules exist for this. So your option is to look at the package documentation on the owner site. – Steve Jun 20 '21 at 20:21

2 Answers2

2

There are certain "naming conventions", that are typically followed, but they are mostly conventions and not enforced, so it can vary from package to package.

Usually, public packages have some tutorials/documentations that show what needs to be used. But you can also use the Class View in Visual Studio to see all the imported namespaces/classes, which is based on the package metadata

If you still cannot make sense of what a package does, it is also possible to use a decompiler like dotPeek (https://www.jetbrains.com/decompiler/), but that might not be allowed depending on the licensing of a package.

CitrusO2
  • 846
  • 10
  • 17
1

The namespace should be using iText;. You can read this api document: https://api.itextpdf.com/iText7/dotnet/7.1.15/namespaces.html

Dylan
  • 504
  • 2
  • 5
  • 9