Alex
Alex

Reputation: 549

How to get Microsoft.Extensions.Http in COM+ to work?

We use IHttpClientFactory in a .NET 4.7 COM+ class. To be able to use IHttpClientFactory, we added the Nuget package Microsoft.Extensions.Http version 7.0, which installed the following dlls in the packages directory:

Microsoft.Bcl.AsyncInterfaces.7.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll
Microsoft.Extensions.DependencyInjection.Abstractions.7.0.0\lib\net462\Microsoft.Extensions.DependencyInjection.Abstractions.dll
Microsoft.Extensions.DependencyInjection.7.0.0\lib\net462\Microsoft.Extensions.DependencyInjection.dll
Microsoft.Extensions.Http.7.0.0\lib\net462\Microsoft.Extensions.Http.dll
Microsoft.Extensions.Logging.7.0.0\lib\net462\Microsoft.Extensions.Logging.dll
Microsoft.Extensions.Logging.Abstractions.7.0.0\lib\net462\Microsoft.Extensions.Logging.Abstractions.dll
Microsoft.Extensions.Options.7.0.0\lib\net462\Microsoft.Extensions.Options.dll
Microsoft.Extensions.Primitives.7.0.0\lib\net462\Microsoft.Extensions.Primitives.dll
System.Buffers.4.5.1\lib\net461\System.Buffers.dll
System.Diagnostics.DiagnosticSource.7.0.0\lib\net462\System.Diagnostics.DiagnosticSource.dll
System.Memory.4.5.5\lib\net461\System.Memory.dll
System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll
System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll
System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll

We installed these dlls in the GAC with gacutil. Upon calling the method HttpClient.PostAsync we get the exception:

Could not load file or assembly 'System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.

  1. What do we have to do, so that COM+ can find this dll?
  2. Is it safe to install the above dlls in the GAC on a production server with Windows Server 2012?
  3. The name "System.Runtime.CompilerServices.Unsafe.dll" does not suggest safeness. Is it really safe for a production environment?
  4. Is it safe to use HttpClientFactory in a COM+ class?
  5. The following solution demonstrates the problem: https://github.com/pappasa/TestHttpClientFactory

Best regards,

Alexandros

Upvotes: 0

Views: 57

Answers (0)

Related Questions