locked
BadImageFormatException: Could not load file or assembly 'System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' RRS feed

  • Question

  • Hi All,

    I have Asp.Net core 2.1 MVC application, and trying to implement Saml2.0 , i am using below code, but the "EntityId" is used by System.IdentityModel.dll is not loading. it is throwing me error

    services.AddAuthentication()
                   .AddSaml2(options =>
                   {
                       options.SPOptions.EntityId = new EntityId("https://localhost:44349/Saml2");
                       options.IdentityProviders.Add(
                           new IdentityProvider(
                               new EntityId("http://localhost:59410//Metadata"), options.SPOptions)
                           {
                               LoadMetadata = true
                           });

                       options.SPOptions.ServiceCertificates.Add(new X509Certificate2("certificatename.cer"));
                   });

    whenever i am running application in local, throws me error, is there any way to implement saml2.0 in asp.netcore 2.1 mvc ? kindly share me the link or solution. Appreciate your effort in advance.


    Sr. MSCRM Constultant

    • Moved by CoolDadTx Monday, July 16, 2018 6:14 PM ASP.NET related
    Monday, July 16, 2018 3:35 PM

All replies

  • Bad Image means you are trying to run a 64 bit program in a 32 bit environment or visa versa. 

    You trying to drop down from a Web application to run a desktop solution is not viable.

    Monday, July 16, 2018 4:08 PM
  • Hi DA924x,

    I am running in 64 bit environment, but the System.IdentityModel.dll 4.0 is from the path below

    C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1

    for 64 bit version, i do not have System.IdentityModel.dll, how can i get this dll for 64 but environment.?


    Sr. MSCRM Constultant

    Monday, July 16, 2018 5:32 PM
  • Please post questions related to ASP.NET in the ASP.NET forums.

    Michael Taylor http://www.michaeltaylorp3.net

    Monday, July 16, 2018 6:13 PM