I keep having issues with the dependent assemblies of Azure.AI.FormRecognizer.4.1.0 in visual studio c# project

Diallo, Mouhamadou S 0 Reputation points
2024-01-30T17:02:19.7566667+00:00

WARNING! There was an error parsing the document

Hello,  
I'm trying to test the Azure.AI.FormRecognizer.4.1.0 in visual studio .net framework 4.8.1 library project solution. Now I've the version 6.0.0.1 of System.Diagnostics.DiagnosticSource in my solution, but when I try to downgrade the assembly assembly 'System.Diagnostics.DiagnosticSource' to the version 6.0.0.0, it will do the following downgrade as well (e.g: Azure.AI.FormRecognizer.4.1.0 to Azure.AI.FormRecognizer.4.0.0). Now if I downgrade to Azure.AI.FormRecognizer.4.0.0, I get the following error message: Could not load file or assembly  System.Diagnostics.DiagnosticSource, Version=4.0.4.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. And after I install System.Diagnostics.DiagnosticSource, Version=4.0.4.0, I get another error message (Could not load file or assembly 'System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'). So I keep getting error after upgrading or downgrading assemblies version. How could I resolve this?  
  
Updates:
Azure.AI.FormRecognizer.4.1.0 -> Azure.AI.FormRecognizer.4.0.0
Azure.Core.1.34.0 -> Azure.Core.1.33.0
System.Diagnostics.DiagnosticSource.6.0.1 -> System.Diagnostics.DiagnosticSource.6.0.0


  
  
Exception thrown: 'System.IO.FileNotFoundException' in Azure.AI.FormRecognizer.dll
An exception of type 'System.IO.FileNotFoundException' occurred in Azure.AI.FormRecognizer.dll but was not handled in user code
Could not load file or assembly 'System.Diagnostics.DiagnosticSource, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The system cannot find the file specified.  
  
![User's image](/api/attachments/cb22b3e9-6ae0-4fc2-a131-909b8e0db635?platform=QnA)  
  


Thanks & Regards,  
Mouhamadou
Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
4,872 questions
Visual Studio Debugging
Visual Studio Debugging
Visual Studio: A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.Debugging: The act or process of detecting, locating, and correcting logical or syntactical errors in a program or malfunctions in hardware. In hardware contexts, the term troubleshoot is the term more frequently used, especially if the problem is major.
966 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Michael Taylor 51,341 Reputation points
    2024-01-30T17:37:07.89+00:00

    Azure.AI.FormRecognizer 4.1.0 requires at least Azure.Core 1.34.0. Azure Core requires at least System.Diagnostics.DiagnosticSource 6.0.1 for .NET Framework 4.7.2 or higher. Since you are targeting 4.8.1 you cannot downgrade DiagnosticSource to 6.0.0. Why are you trying to downgrade?

    Downgrading packages can get tricky because of binding redirects. If you want to downgrade to Azure.AI.FormRecognizer 4.0.0 then downgrade the package using NuGet Package Manager. After that you'll need to fix up the binding redirects. I assume that you have an app/web.config file for your executable. Inside there is a binding redirect element that lists all the assemblies that you rely on and their version. You need to adjust the binding for any package you downgrade to use the version of the assembly that you are now targeting. As example if you updated to 4.1.0 then you most likely had something like this.

    <dependentAssembly>
      <assemblyIdentity name="Azure.AI.FormRecognizer"
        publicKeyToken="..." culture="en-us" />
      <bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0" />
    </dependentAssembly>
    

    You'll need to change the old and new versions to be 4.0.0.0. You'll need to do that for all the dependencies you downgrade as well. Be aware that sometimes a Nuget version doesn't match the assembly version. You have to use the assembly version. You should search the remaining sections of the config file to see if the assembly is referenced elsewhere as there may be additional references to the versioned assembly you need to update.