Problem explained
The PowerBuilder project contains a .Net assembly that uses RestSharp to execute a GET call to the address https://www.google.de. When executing in PowerBuilder, the error message Could not load file or assembly ... appears. The problem is that PowerBuilder expects an assembly in a specific version. The assembly is available, but in a newer version. This can also be seen in pb-example-error.dll.config.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>Solution
When generating the DLLs, Costura Fody creates a single DLL, which means that all dependencies are self-contained and the error is corrected.
Example project
The sample project is located in Gitlab: https://github.com/tobiasoehler/PowerBuilder-DLL-Version-Problem-RestSharp

Leave a Reply