Reputation: 3118
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.
Upvotes: 3
Views: 1035
Reputation: 100581
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.
Upvotes: 9