I’ve been trying to implement proper Dependency Injection using Microsoft.Extensions.DependecyInjection and Microsoft.Extensions.Hosting but I keep running into this error whenever I try build my HostBuilder “Could not load file or assembly 'System.Diagnostics.DiagnosticSource, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified”. I would appreciate any help, thank you.
I haven't used Microsoft.Extensions.Hosting, however, it looks like your app seems to look for .NET 7. ArcGIS Pro is built on .NET 6.
The issue is that I do not have that version of 'System.Diagnostics.DiagnosticSource' installed.
System.Diagnostics.DiagnosticSource is part of the .NETCore app framework, so i am pretty sure if you install the .NET 7 runtime you have the desired assembly version.
I downloaded and installed the runtime, still the the same error. Super weird. I apologize for the inconvenience.
I figured it out! I had change the installation directory for ArcGIS Pro! 😁
Not sure how the installation directory for ArcGIS Pro would fix the “Could not load file or assembly 'System.Diagnostics.DiagnosticSource, Version=7.0.0.0, C..." issue. Can you elaborate? Where did you install ArcGIS Pro?
By default it installed in the AppData. When I installed it in ProgramFiles the error was resolved. I'm assuming there was a possible permissions issue?
Also, the Microsoft.Extensions.Configuration.Abstractions dll (Version 2.0.0.0) located in the ArcGIS Pro folder is interfering with the Microsoft.Extensions.Configuration.Abstractions Version 6.0.0 package installed in the AddIn project.
I'm looking to do something similar. Where in your module code/how did you set up your container? I'd love to see any sample code you're willing to share!