I am creating a class library that will be used in a WPF project and a .NET Core project.
For the following code:
public class MyClass
{
private void MyFunction(object o)
{
if (o == DBNull)
{
//ommitted
}
}
}
I am getting the following error:
The name 'DBNull' does not exist in the current context
This is a .NET Standard Class Library Project created in Visual Studio 2017.
Both my .NET Core project and WPF Project allow the use of DBNull.
You need to add the NuGet package System.Data.Common
to your project to be able to use DBNull
in netstandard1.4
via the NuGet package manager or via console:
dotnet add package System.Data.Common
In .NET Standard 2.0, it will be available automatically.