Getting error after compiling custom project from Visual studio in Acumatica 21R1

Could not load file or assembly 'Microsoft.Bcl.AsyncInterfaces' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.IO.FileLoadException: Could not load file or assembly 'Microsoft.Bcl.AsyncInterfaces' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

I have to keep a backup copy of the dll and replace it again for the site to come up. How to fix the issue

Upvotes: 1

Views: 2276

Answers (3)

Kulvir
Kulvir

Reputation: 544

I noticed the web.config for build 21.106.0024 (under Acumatica ERP 2021 R1 21.106.0024\Acumatica ERP\Files) shows the following:

  <dependentAssembly>
    <assemblyIdentity name="Microsoft.Bcl.AsyncInterfaces" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
  </dependentAssembly>

But the installed instance of Acumatica for the same build version shows:

  <dependentAssembly>
    <assemblyIdentity name="Microsoft.Bcl.AsyncInterfaces" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-1.0.0.0" newVersion="1.0.0.0" />
  </dependentAssembly>

So I commented out the 1.0 version and put in the 5.0 version and it worked:

  <dependentAssembly>
    <assemblyIdentity name="Microsoft.Bcl.AsyncInterfaces" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
    <!--<bindingRedirect oldVersion="0.0.0.0-1.0.0.0" newVersion="1.0.0.0" />-->
    <bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
  </dependentAssembly>

That workaround works for local development without issues but there is a bug with the installer I believe. Strange that the web.config looks correct from the installed files but not when a new instance is created.

Upvotes: 2

MikeNIke
MikeNIke

Reputation: 233

I got past this by referencing the Microsoft.Bcl.AsyncInterfaces DLL in my DLL project. The DLL project that I've made is set to put the DLL directly into the bin directory of the Acumatica web site. This works when I have the Acumatica website included in the Visual Studio project. .Net 4.8, Acumatica 2021 R2, Visual Studio 2019

The Microsoft.Bcl.AsyncInterfaces.dll that will appease Acumatica is in the C:\Program Files\Acumatica ERP\Files\Bin folder.

Upvotes: 0

Hugues Beaus&#233;jour
Hugues Beaus&#233;jour

Reputation: 8278

EDIT: The root cause of the error is likely that you have a reference to Microsoft DLL in your Acumatica DLL extension project.

enter image description here

And you also likely have a Website in the same solution which adds the extension projection reference. To check this, right click Website go to Property Pages and check in References, with Add Reference button in Project reference section. enter image description here

This setup copies references automatically when you compile. You can remove copying of some references with CopyLocal=False property. However this doesn't appear to apply for Microsoft.Bcl.AsynInterfaces. Maybe you used Bind feature in Acumatica Customization page to set-up that automatic copying or created the extension C# project from the Acumatica Customization page.


In case the website is broken by a DLL file in Acumatica Bin directory. To restore original DLL files use Acumatica ERP Wizard (same version as corrupted website) and select 'Perform Application Maintenance' enter image description here

Then select the corrupted site and run 'Update Only Website': enter image description here

Check the date of the DLL which was previously corrupted: enter image description here

Then identify the process which replaces the original DLL file shipped with Acumatica by a incompatible version and remove it. I suspect you are compiling a C# project in Visual Studio. And this project is configured to deploy files directly into Acumatica Bin directory. After compilation the date of the corrupted DLL file would change in Acumatica Bin folder.

Try removing the website from your solution if it's there and has a reference to your C# Acumatica extension project:

enter image description here

If there's a Post Build script (project properties-> build) that replace Acumatica DLL remove it.

Then compile to any directory that isn't Acumatica Bin folder. This is configured in C# project properties build section. enter image description here

After compilation copy only the required compiled files which does not include 'Microsoft.Bcl.AsyncInterfaces.dll' to Acumatica Bin folder.

This copy operation can be done manually, with a batch file, with a post build script etc... The important thing is that it shouldn't copy DLL files which are already shipped with Acumatica.

One other possible solution is to select the same .Net Framework version that the Acumatica site uses in your own extension DLL. That way when compiling you would be replacing Microsoft DLL with the same version.

Upvotes: 2

Related Questions