How to handle binding redirect within a custom plugin?

How to handle binding redirect within a custom plugin?

edfdiloreto
Contributor Contributor
1,133 Views
3 Replies
Message 1 of 4

How to handle binding redirect within a custom plugin?

edfdiloreto
Contributor
Contributor

I need to manually binding redirect some dlls and I can't make it work. Example:

 

  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.3.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>

 

It's seems like Autocad doesn't detect the plugin .config file. Does anyone have a solution for this?

0 Likes
Accepted solutions (1)
1,134 Views
3 Replies
Replies (3)
Message 2 of 4

norman.yuan
Mentor
Mentor

By saying "...the plugin .config file", I assume you mean "xxxx.dll.config". No, AutoCAD does not load xxx.dll.cofig, nor any other .NET exe app loads it, for that matter. You need to merge the content of this xxxx.dll.config into the xxx.exe.config (e.g. Acad.exe.config) if you want the setting being read into the exe app when it starts up.

 

Also, System.Buffers is not part of .NET framework, you use NuGet to add certain version of it to your project. Therefore, the referenced System.Buffer dll(s) will be deployed with your .NET APP together with the version obtained via Nuget. So, why do you need to do "binding redirect" (it is not like you have multiple versions of .NET frameworks, thus multiple versions of "System.Buffers")?

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 3 of 4

edfdiloreto
Contributor
Contributor

Thanks for the answer. In my plugin I'm using WPF with MvvmToolkit in order to create a GUI following the MVVM architecture. I have exactly this problem: https://github.com/CommunityToolkit/dotnet/issues/86 , where MvvmToolkit cannot find the correct dll version of System.Buffer.

 

It's seems like the only way to solve is manually add the binding references.

 

 

0 Likes
Message 4 of 4

norman.yuan
Mentor
Mentor
Accepted solution

I never have "Nuget"ed System.Memery/System.Buffers, thus have not experienced this issue. If you want add "binding redirect" into .config file, then it is acad.exe.config. So, you can simply try to add that portion of configuration into acad.exe.config file and see what happens.

Norman Yuan

Drive CAD With Code

EESignature