Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to instanciate OktaClient with .NET Standard 2.0 #515

Closed
christophecolly opened this issue Oct 31, 2021 · 9 comments
Closed

Unable to instanciate OktaClient with .NET Standard 2.0 #515

christophecolly opened this issue Oct 31, 2021 · 9 comments

Comments

@christophecolly
Copy link

christophecolly commented Oct 31, 2021

Hi,

I'm using version 5.2.1 of the Okta.Sdk and trying to instantiate a client in a .NET Standard 2.0 console app:

using System;
using Okta.Sdk;
using Okta.Sdk.Configuration;

namespace OktaSdk1
{
    internal class Program
    {
        static void Main(string[] args)
        {
            var client = new OktaClient(new OktaClientConfiguration
            {
                OktaDomain = "https://domain.okta.com",
                Token = "myApiToken"
            });
        }
    }
}

.csproj project file:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netstandard2.0</TargetFramework>
    
    <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>

  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Okta.Sdk" Version="5.2.1" />
  </ItemGroup>

</Project>

I get the following error when trying to debug:

Unhandled Exception: System.IO.FileLoadException: Could not load file or assembly 'Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
   at Okta.Sdk.Abstractions.Configuration.Providers.Object.ObjectExtension.AddObject(IConfigurationBuilder builder, Object object, String root)
   at Okta.Sdk.OktaClient.GetConfigurationOrDefault(OktaClientConfiguration apiClientConfiguration)
   at Okta.Sdk.OktaClient..ctor(OktaClientConfiguration apiClientConfiguration, ILogger logger, ISerializer serializer)
   at OktaSdk1.Program.Main(String[] args) in C:\Users\user\source\repos\OktaSdk\OktaSdk\Program.cs:line 11

If I change Okta.Sdk version to 5.2.0 it works.
If I change to .NET 5 instead of .NET Standard 2.0 it works.

Any help would be much appreciated.

@andriizhegurov-okta
Copy link
Contributor

Hi @christophecolly, thank you for reporting the issue. I apologize for the inconvenience.
We will investigate it internally and update you here.
Please use Okta.Sdk version 5.2.0 meanwhile. Version 5.2.1 uses different configuration dependencies but in terms of functionality, 5.2.0 and 5.2.1 are the same.

@christophecolly
Copy link
Author

Thanks for your feedback, I will use 5.2.0 for now.

@Christian-Oleson
Copy link
Contributor

Thanks for your feedback, I will use 5.2.0 for now.

@christophecolly ,
Did that actually fix your issue? I have a similar issue and the downgrade did not fix it for me.

@christophecolly
Copy link
Author

christophecolly commented Nov 9, 2021

@Christian-Oleson Yes I can confirm that downgrading to 5.2.0 fixes the issue for me. Are you also targeting .NET Standard 2.0?

@Christian-Oleson
Copy link
Contributor

@Christian-Oleson Yes I can confirm that downgrading to 5.2.0 fixes the issue for me. Are you also targeting .NET Standard 2.0?

I'm not, I'm targeting .NET 5.

@christophecolly
Copy link
Author

For me it works as expected with .NET 5 and SDK 5.2.1.

@Christian-Oleson
Copy link
Contributor

For me it works as expected with .NET 5 and SDK 5.2.1.

Thank you for confirming!

@93ramadan
Copy link

93ramadan commented Dec 28, 2021

Hello
I am using .net core 3.1 and facing this issue - what’s the recommended fix please (besides upgrading to .net 5)?
Much appreciate

@andriizhegurov-okta
Copy link
Contributor

This should be fixed in Okta.Sdk v5.3.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants