Problem with adding Auth0 Package in .NET Standart project

azattuazattu Member

Hello,

Facing issue when trying add Auth0.OidcClient to my Xamarin project.

Steps done:

  1. Installed Auth0.OidcClient.Android and Auth0.OidcClient.iOS packages for appropriate directories.

  2. Added following code in page.cs:

    using Auth0.OidcClient;
    ...
    
     var client = new Auth0Client(new Auth0ClientOptions
            {
                Domain = "dragonsms.auth0.com",
                ClientId = "Wc7X2k5Rn2eCetr4pOlgWmUbsGrV9V4L"
            });
            var loginResult = await client.LoginAsync();
        }
    

When try to run getting following:

Error CS0246: The type or namespace name 'Auth0' could not be found (are you missing a using directive or an assembly reference?)

P.S.

In PCL project everything working fine

Answers

  • batmacibatmaci DEMember ✭✭✭✭✭

    I dont know about this library but this error message appears for 2 reason generally

    • you installed it only on shared library and it expects you to install on android or ios projects
    • It support .net standard but not xamarin.

    It is paid solution why dont you consult their support. i am sure that they will give you a good answer.

  • JGoldbergerJGoldberger USMember, Forum Administrator, Xamarin Team, University Xamurai

    It doesn't look like that library is built for use in a .NET Standard project. As suggested by batmaci, you should consult the library author about .NET Standard project support.

    You can still use it, but if you want to have your code run from the .NET Standard project, you will have to do some dependency injection, which you can do using the Xamarin.Forms DependencyService.

    Xamarin.Forms allows developers to define behavior in platform-specific projects. DependencyService then finds the right platform implementation, allowing shared code to access the native functionality.

Sign In or Register to comment.