I'm using ZWCAD 2023 and following the 2023 .NET Developing Guide (https://www.zwsoft.com/support/zwcad-devdoc). I createad a Framework 4.7.2 app (also tried 4.7, as both are showing in the guide). Then, added the DLLs from my installation folder, and disabled Copy Local. When debugging, I get the following exception:
System.IO.FileNotFoundException: 'Could not load file or assembly 'ZwDatabaseMgd, Version=23.1.23.1, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the specified file.'
I tried to edit my App.config to force a version (this is the same version as shown in Windows file details).
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="ZwDatabaseMgd" publicKeyToken="null" culture="neutral"/>
<codeBase version="23.0.2.4" href="C:\Program Files\ZWSOFT\ZWCAD 2023\ZwDatabaseMgd.dll"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="ZwManaged" publicKeyToken="null" culture="neutral"/>
<codeBase version="23.0.2.4" href="C:\Program Files\ZWSOFT\ZWCAD 2023\ZwManaged.dll"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
But then I got the following exception:
System.BadImageFormatException: 'Could not load file or assembly 'ZwDatabaseMgd, Version=23.1.23.1, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format.'
I changed the Platform target to x64 and got the following exception:
System.IO.FileLoadException: 'Could not load file or assembly 'ZwDatabaseMgd, Version=23.1.23.1, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The assembly was found outside the appbase directory. (Exception from HRESULT: 0x80131041)'
I looked this exception, and most of the results suggested I should 'Unblock' my file, but this option wasn't available in the dll properties. And as you can see, even after editing my App.config, it still looks for the wrong version. Any suggestions?
Edit: I read that I should set the Public Key Token in the App.config. When I used this command on PowerShell, to find out the key, I found out the correct version is actually 23.1.23.1:
([system.reflection.assembly]::loadfile("C:\Program Files\ZWSOFT\ZWCAD 2023\ZwDatabaseMgd.dll")).FullName
ZwDatabaseMgd, Version=23.1.23.1, Culture=neutral, PublicKeyToken=null