okta / okta-sdk-dotnet

A .NET SDK for interacting with the Okta management API, enabling server-side code to manage Okta users, groups, applications, and more.
Other
160 stars 100 forks source link

Error - Could not load file or assembly 'Okta.Sdk, Version=5.6.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. A strongly-named assembly is required. (Exception from HRESULT: 0x80131044) #562

Closed mohitlwcc closed 2 years ago

mohitlwcc commented 2 years ago

Describe the bug?

Hi,

I am trying to use OKTA SDK with my ASP.NET C# MVC project. When I try to call api to create user it gives be below error:

"Could not load file or assembly 'Okta.Sdk, Version=5.6.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. A strongly-named assembly is required. (Exception from HRESULT: 0x80131044)"

My project has .snk file so does it has anything to do with this error?

Thank you!

What is expected to happen?

API should create user.

What is the actual behavior?

Throwing error

Reproduction Steps?

NA

Additional Information?

No response

.NET Version

4.5

SDK Version

5.6.0.0

OS version

No response

bryanapellanes-okta commented 2 years ago

@mohitlwcc Thanks for reaching out! Yes, because your project has an .snk file it requires all referenced assemblies to also be strong named. I believe, for simplicity, the Okta Sdk assemblies are not strong named which is the cause of the issue you are seeing. If it's an option, I'd suggest for you not to sign your assembly in order to reference the Okta.Sdk; however, if this is not an option, you can create a custom build using the Okta.Sdk source if necessary.

mohitlwcc commented 2 years ago

Thanks, Bryan, for getting back to me. I think we are not going to opt out of strongly named assembly so can you guide me on how to create a custom build okta.sdk?

Regards,

@.*** Mohit Patel .Net Developer [O] 1 (225) 231-0751<tel:1%20(225)%20231-0751>

From: Bryan Apellanes @.> Sent: Tuesday, July 5, 2022 3:20 PM To: okta/okta-sdk-dotnet @.> Cc: Patel, Mohit @.>; Mention @.> Subject: Re: [okta/okta-sdk-dotnet] Error - Could not load file or assembly 'Okta.Sdk, Version=http://5.6.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. A strongly-named assembly is ...

@mohitlwcchttps://github.com/mohitlwcc Thanks for reaching out! Yes, because your project has an .snk file it requires all referenced assemblies to also be strong named. I believe, for simplicity, the Okta Sdk assemblies are not strong named which is the cause of the issue you are seeing. If it's an option, I'd suggest for you not to sign your assembly in order to reference the Okta.Sdk; however, if this is not an option, you can create a custom build using the Okta.Sdk source if necessary.

— Reply to this email directly, view it on GitHubhttps://github.com/okta/okta-sdk-dotnet/issues/562#issuecomment-1175462507, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AZ5WBHYS3TJIE36HDNWH4ZTVSSKIDANCNFSM52WWHDTA. You are receiving this because you were mentioned.Message ID: @.**@.>>

bryanapellanes-okta commented 2 years ago

@mohitlwcc To create a custom build do the following:

You will now have a custom Okta.Sdk.dll binary with a strong name found in the "bin" directory.

mohitlwcc commented 2 years ago

@bryanapellanes-okta Thank you for the guidance. Just want to make sure one thing that if I do custom build sdk and in future if Okta updated something does it going to break anything on my side? Or If any change on okta side takes place does my custom build okta sdk will break?

bryanapellanes-okta commented 2 years ago

@mohitlwcc If changes are necessary in the future to update the Sdk to support new features of the API then you would need a new custom build to take advantage of those features. We endeavor not to make breaking changes without appropriate communication beforehand.

mohitlwcc commented 2 years ago

Hi @bryanapellanes-okta ,

After referring to custom build sdk dll, I am getting below error when I call:

client.Users.GetUserAsync("abc@gmail.com");

CS7069: Reference to type 'IAsyncEnumerable<>' claims it is defined in 'netstandard', but it could not be found

Any Idea?

mohitlwcc commented 2 years ago

This are the error I am seeing in error list:

image

mohitlwcc commented 2 years ago

@bryanapellanes-okta Never mind I was able to resolve that error. But run into another one. Now I have strongly name okta.sdk dll so now it is looking for strongly name okta.sdk.abstraction. Do you know how to get that one?

bryanapellanes-okta commented 2 years ago

@mohitlwcc You can find the Okta.Sdk.Abstractions in this repo: https://github.com/okta/okta-sdk-abstractions-dotnet

mohitlwcc commented 2 years ago

Just going with unsigned assembly approach.