Author Topic: Problem using RabbitMQ with VoiceAttack Plugin  (Read 3981 times)

BaslimJubbul

  • Newbie
  • *
  • Posts: 5
Problem using RabbitMQ with VoiceAttack Plugin
« on: October 18, 2021, 04:10:50 PM »
I'm trying to integrate RabbitMQ into my VoiceAttack Plugin to provide a rich message queuing service. I've got RabbitMQ and its dependencies installed (via chocolaty) on Windows 10, and have written/compiled/run test programs to show it works. But when I try to call the `CreateConnection` method in the RabbitMQ C# client DLL, I get an exception  "Could not load file or assembly 'System.Threading.Tasks.Extensions, Version=4.2.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The system cannot find the file specified." Debugging the call statement and the exception it returns, I can see an inner exception with the following message.

"=== Pre-bind state information ===
 LOG: DisplayName = System.Threading.Tasks.Extensions, Version=4.2.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51 (Fully-specified)
 LOG: Appbase = file:///C:/Program Files/VoiceAttack/
 LOG: Initial PrivatePath = NULL
 Calling assembly : System.Threading.Channels, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51.
 ===
 LOG: This bind starts in LoadFrom load context.
 WRN: Native image will not be probed in LoadFrom context. Native image will only be probed in default load context, like with Assembly.Load().
 LOG: No application configuration file found.
 LOG: Using host configuration file:
 LOG: Using machine configuration file from C:\\Windows\\Microsoft.NET\\Framework64\\v4.0.30319\\config\\machine.config.
 LOG: Post-policy reference: System.Threading.Tasks.Extensions, Version=4.2.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
 LOG: The same bind was seen before, and was failed with hr = 0x80070002.
 "
  I have downloaded the latest System.Threading.Tasks.Extensions.dll from NuGet, and have put it into the VA directory, the Shared/assemblies subdirectory, and my plugin subdirectory, all with no success

 Googling this error message, it seems to happen to a number of people integrating Rabbit MQ with their (non-voiceattack) applications, whne doing so in a multi-project (main plus plugins) application. The consensus workaround is to add an app.config file with a binding redirect, but when I try that workaround:
 `VoiceAttack.exe.config (placed in the \Program Files\VoiceAttack directory):
 code:
<?xml version="1.0" encodeing="utf-8" ?>
<configuration>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Threading.Tasks.Extensions" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.2.0.1" newVersion="4.2.0.2" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>
endcode:

Starting VA pops up an error message that "the application has failed to start because its side-by-side configuration is incorrect". Running `sxstrace` to get details on THAT error, all I see is
=================
Begin Activation Context Generation.
Input Parameter:
   Flags = 0
   ProcessorArchitecture = AMD64
   CultureFallBacks = en-US;en
   ManifestPath = C:\Program Files\VoiceAttack\VoiceAttack.exe
   AssemblyDirectory = C:\Program Files\VoiceAttack\
   Application Config File = C:\Program Files\VoiceAttack\VoiceAttack.exe.Config
-----------------
INFO: Parsing Application Config File C:\Program Files\VoiceAttack\VoiceAttack.exe.Config.
   ERROR: Line 0: XML Syntax error.
ERROR: Activation Context generation failed.
End Activation Context Generation.

=================

I can't find anything wrong with the XML in that file. The file is utf-8, I tried both with and without a BOM.

So, after 12 hours down this "rabbit" hole, I thought I'd ask the community if anyone has run into this or a similar problem? I'll keep plugging away at it, and will certainly post the solution to integrating RabbitMQ with a VoiceAttack Plugin if I can find one.

BaslimJubbul

  • Newbie
  • *
  • Posts: 5
Re: Problem using RabbitMQ with VoiceAttack Plugin
« Reply #1 on: October 19, 2021, 12:37:38 AM »
Ah, it is always a little typo somewhere...  the problem with the XML file was the misspelling of "encodeing" ("encoding" is correct). The second problem was that the `newversion` should be 4.2.0.1 - that is what ILSpy shows to be the DLL version when I download `System.Threading.Tasks.Extensions` Version 4.5.4 from NuGet.  Now the 'sxstrace' logs show no errors. The details show that the `VoiceAttack.exe.config` file was accepted, and shows that a binding redirect took place.

I still have an exception when trying to connect to the rabbitMQ server ("connection.start was never received, likely due to a network timeout"), but that's a problem for another day and another forum :-). Once I get RabbitMQ working, I'll be back here to publish further details on how I made it work with a VoiceAttack Plugin.