ALERT: Some images may not load properly within the Knowledge Base Article. If you see a broken image, please right-click and select 'Open image in a new tab'. We apologize for this inconvenience.
C# A2A example not working in Visual Studio 2017
Article ID: 103159
CA Privileged Access Manager - Cloakware Password Authority (PA)PAM SAFENET LUNA HSMCA Privileged Access Manager (PAM)
When attempting to build/compile the A2A Example for C#_64 in Visual Studio 2017 with .Net version 4.0, Visual Studio throws the following error:
System.BadImageFormatException: 'Could not load file or assembly 'Interop.Cspmclientc64, Version=126.96.36.199, Culture=neutral, PublicKeyToken=null' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.'
PAM 3.x A2A 3.x
The error that is due to the fact that we cannot find the file:
Inside the sample same code, we state that you must:
// To use the CSPM DLL, first add a reference to the DLL. // To do this, select Project, Add Reference // Select the COM tab // Select Browse // Select the Cspmclientc64. // Click Open // Click OK
Additionally for Visual Studio 2017 with .NET version 4, the code must be updated to:
Cspmclientc64.ccspmclientc64 c = new Cspmclientc64.ccspmclientc64(); instead of: Cspmclientc64.ccspmclientc64class c = new Cspmclientc64.ccspmclientc64class();
This is an addendum to this KB article #103159 pointed to by link - https://knowledge.broadcom.com/external/article?articleId=103159. Using Visual Studio version VS2019, customer was running into the error below post following the steps in this KB article.
The issue was resolved by suggestion pointed to by the link - https://stackoverflow.com/questions/3456758/a-reference-to-the-dll-could-not-be-added/12639732#12639732. The relevant excerpt is added as a screenshot below.