This topic provides information about the following:
What are NuGet Packages?
NuGet is the package manager for the Microsoft development platform that includes .NET. NuGet packages make it easy to add, remove, and update libraries and tools in Visual Studio projects that use the .NET Framework.
To read more about NuGet, please visit nuget.org.
Installing NuGet
The NuGet package manager is installed with Visual Studio, since version 2012.
Windows NuGet command line instruction for installation can be found at https://docs.microsoft.com/en-us/nuget/install-nuget-client-tools
SmartZone NuGet Packages
SmartZone has a single convenience meta package, Accusoft.SmartZone.Net, that includes dependency references to OCR, ICR and Runtime packages (both Windows and Linux). This allows you to get started quickly. If you do not need all of this, you can also add the ICR and/or OCR packages individually to your project, together with the desired Windows and/or Linux runtime(s). This gives you more control and less overhead on packages you may not need.
If your project needs Asian language support, you will need to add the Asian language support runtime package to your project (Windows and/or Linux).
Package Id |
Description |
Assemblies |
Package Dependencies |
Accusoft.SmartZone.Net |
The SmartZone™ Combined NuGet package contains all you need to get started quickly, including the SmartZone™ ICR and OCR packages, and both Windows and Linux runtimes. |
None |
Accusoft.SmartZoneICR.Net Accusoft.SmartZoneOCR.Net Accusoft.SmartZone.Runtime.Win Accusoft.SmartZone.Runtime.Lin |
Accusoft.SmartZoneICR.Net |
The SmartZone™ ICR component contains all the necessary objects, methods, and properties it takes for you to perform high accuracy zonal and full page ICR recognition. |
Accusoft.SmartZoneICR.Net.dll |
.NETFramework, Version=3.5 .NETStandard, Version=2.0 |
Accusoft.SmartZoneOCR.Net |
SmartZone™ OCR performs OCR recognition in user defined areas of interest (i.e zones) or full page. SmartZone OCR can be easily integrated with other Accusoft components into a robust forms-processing product. Note that this package needs the OS specific runtime package to be added as an extra dependency to your project. |
Accusoft.SmartZoneOCR.Net.dll |
.NETFramework, Version=3.5 .NETStandard, Version=2.0 |
Accusoft.SmartZone.Runtime.Win |
SmartZone language resources for Windows (x86, x64). |
None |
None |
Accusoft.SmartZone.Runtime.Lin |
SmartZone language resources for Linux (x64). |
None |
None |
Accusoft.SmartZone.Runtime.Asian.Win |
SmartZone Asian language resources for Windows (x86, x64). |
None |
None |
Accusoft.SmartZone.Runtime.Asian.Lin |
SmartZone Asian language resources for Linux (x64). |
None |
None |
Package Accusoft.SmartZone.Runtime.Win replaces the package Accusoft.SmartZone.Runtime.Latin.Win from SmartZone 6.0.
Packages Accusoft.SmartZone.Runtime.Win/Lin and (optional) Accusoft.SmartZone.Runtime.Asian.Win/Lin provide .props and .targets files that will automatically copy native resources during builds.
Package Accusoft.SmartZone.Net includes dependency references to the appropriate runtime package(s) Accusoft.SmartZone.Runtime.Win/Lin. These will be installed automatically when adding the former packages using Visual Studio (see Adding SmartZone NuGet Packages below). When your build system uses a NuGet version before 5.0 (typically used by Visual Studio 2017 and older), you should explicitly add the runtime packages to your project even if another NuGet package with this dependency has already been added to that project. Otherwise, the native resources will not be copied during builds.
Adding SmartZone NuGet Packages
Once installed, SmartZone ICR and OCR will have evaluation mode activated by default. To continue developing or deploying with SmartZone, you will need a paid license. Refer to Licensing and Distributing for more information.
All of our packages can be found at nuget.org, which is the central package repository used by all package authors and consumers. The NuGet Package Manager is configured, by default, to use nuget.org for packages' sources.
From Visual Studio
-
Open the NuGet Package Manager in Visual Studio by right-clicking on the project or solution in the Solution Explorer, and choose Manage NuGet packages.
-
In the opened window make sure that Package source is set to nuget.org.
-
Select Browse at the top-left of the page, and type Accusoft.SmartZone.Net into the search bar to find the package.
-
Select the package on the left and then click the Install button on the right.
After installing the required package, you should see the newly added Accusoft.SmartZoneICR.Net and Accusoft.SmartZoneOCR.Net assemblies (and their dependencies) in your application's References folder.
-
SmartZone OCR Asian Language Recognition requires installing the package Accusoft.SmartZone.Runtime.Asian.Win. If your app does not use SmartZone to recognize Chinese, Japanese, Korean, Thai or Vietnamese languages, this optional dependency can be omitted.
-
Add the SmartZone ICR (or SmartZone OCR) namespace to any C# or VB.NET source file where you want to reference its classes:
ICR
using Accusoft.SmartZoneICRSdk;
OCR
using Accusoft.SmartZoneOCRSdk;
Native binaries and additional resources are copied to your app's output directory after building your project.
To learn more, we also recommend following the official tutorials available at nuget.org: https://docs.nuget.org/consume/package-manager-dialog
Customizing SmartZone NuGet Packages
Accusoft.SmartZone.Runtime.Win & Accusoft.SmartZone.Runtime.Asian.Win
The required OCR language resource files are copied to folder $(OutDir)assets after the MSBuild Target "Build" completes, and copied to the folder $(PublishDir)assets after the MSBuild Target "Publish" completes. By default, this directory is expected to be adjacent to the Accusoft.SmartZoneOCR.Net.dll assembly at runtime.
To change this location to a different directory:
- Override the MSBuild property Accusoft_SmartZone_OCRDataPath in your project.
-
Example: To target a different directory name, such as $(OutDir)my_app
<PropertyGroup> <Accusoft_SmartZone_OCRDataPath>$(OutDir)my_app</Accusoft_SmartZone_OCRDataPath> </PropertyGroup>
- Provide this new location to SmartZone OCR with its OCRDataPath property before recognition is performed.
Uninstalling the Accusoft.SmartZone.Runtime.Win and Accusoft.SmartZone.Runtime.Asian.Win packages does not delete resource files copied from building your application.
Troubleshooting
The troubleshooting section covers some common issues you may encounter and how to resolve them.
NuGet Package Restore Failed: (The Specified Path, File Name or Both are too long.)
NuGet Package restore failed for project [ProjectName]: The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters...
To remedy, do one of the following:
- Enable long path support. See article Long Path Support (NuGet CLI).
- Override the location in which to install NuGet packages using a nuget.config file with a repositoryPath (packages.config only) or globalPackagesFolder (projects using PackageReference only) to provide a shorter path. See article nuget-config-file reference.
- Relocate your project to a directory with a shorter path.
The Specified Path, File Name, or Both are Too Long. (Accusoft.SmartZone.Runtime.Win Only)
During a build, Target "CopyAccusoftSmartZoneRuntimeWin" can fail copying OCR language resources:
error MSB4023: Cannot evaluate the item metadata "%(Filename)". The item metadata "%(Filename)" cannot be applied to the path "XXXX". The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
To remedy, do one of the following:
Internal Error: Remote OCR engine initialization error. The provided search location for SmartZone.OCRDataPath may be invalid.
At runtime, an exception can result when SmartZoneOCR Reader.AnalyzeField is called and OCR language files are not found:
SmartZoneOCRException: Internal Error: Remote OCR engine initialization error. The provided search location for SmartZone.OCRDataPath may be invalid. This issue may be the result of misconfiguration or an incomplete build after NuGet packages are restored.
To remedy, try the following:
- Set OCRDataPath to the expected folder containing OCR language resource files before AnalyzeField is called. By default, this location is expected to be $(OutDir)assets, but can be overridden with MSBuild property $(Accusoft_SmartZone_OCRDataPath).
- Add the appropriate runtime package Accusoft.SmartZone.Runtime.Win or Accusoft.SmartZone.Runtime.Lin (and optionally Accusoft.SmartZone.Runtime.Asian.Win or Accusoft.SmartZone.Runtime.Asian.Lin) to the Visual Studio project and rebuild.