I am currently develop an new page for my web application using C# asp.net. My purpose is to use google authenticator as a 2FA authentication.
Below is my code.
using Google.Authenticator;
Dictionary<String, String> result = new Dictionary<String, String>();
TwoFactorAuthenticator tfa = new TwoFactorAuthenticator();
var setupInfo = tfa.GenerateSetupCode("XXXX", "TITLEXXX", "CODEXXXX", 300, 300);
var result = tfa.ValidateTwoFactorPIN("XXSSWWW", "XXXXWWW");
But in tfa.GenerateSetupCode and tfa.ValidateTwoFactorPIN there is an error as below show.
The type "Object" is defined in an assembly that is not referenced. You must add a reference to assembly 'netstand. version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'
I tried to search online for the solutions. What I have tried:
- Change my web application Target Framework from .NetFramework 4.6.1 to .NetFramework 4.8
- Uninstall and reinstall Google.Authenticator 3.0.0 nuget package.
But above action is not helping me to solve the solution. Anyone know what the issue is and how to solve it?
You need to install the .NET Standard 2.0 nuget package. Right click on your Project in Visual Studio and Browse for NETStandard.Library