3

I have a .NET Framework library provided by a vendor (CyberSource payment processor - https://github.com/CyberSource/cybersource-sdk-dotnet).

This API is being referenced by an ASP.NET Core 3.0 application.

Everything compiles fine but when I attempt to call a method in the .NET Framework library, I get the following exception:

{"Method not found: 'Void System.ServiceModel.EndpointAddress..ctor(System.Uri, System.ServiceModel.EndpointIdentity, System.ServiceModel.Channels.AddressHeaderCollection)'."}

Things I've determined:

  • Vendor doesn't provide a .NET Core or .NET Standard -compliant library
  • Library source is not portable as-is to .NET Standard or .NET Core

Is there any reasonable way to make this work?

Ian Kemp
  • 28,293
  • 19
  • 112
  • 138
user1142433
  • 1,413
  • 3
  • 17
  • 34

1 Answers1

2

You can analyze the DLL with The .NET Portability Analyzer. If all classes and methods that the DLL uses are available in .NET Standard/.NET Core then CLR will be able to call those methods. But some apis are not yet ported and that can be what you are facing. If that's the case, you may be able to fork and rewrite the code to use APIs available in .NET Core 3.

Ian Kemp
  • 28,293
  • 19
  • 112
  • 138
Andrii Litvinov
  • 12,402
  • 3
  • 52
  • 59
  • Portability Analyzer is giving a 75% portability report. It's not an option for us to rewrite their library at this point. – user1142433 Jan 09 '20 at 22:26
  • I have installed System.ServiceModel.Primitives package and EndpointAddress indeed does not have default ctor. Can you target `net48` instead of `netcoreapp3.1` if fork/modify is not an option? That can work. – Andrii Litvinov Jan 09 '20 at 22:43
  • Asp.Net 3 requires Core 3.0 - it's not compatible with net48. – user1142433 Jan 09 '20 at 22:47
  • Ah, I missed that you use asp.net core 3. In that case you can consider downgrading to asp.net core 2.1, which is LTS release and is supported till 2021-08-21 https://dotnet.microsoft.com/download/dotnet-core. – Andrii Litvinov Jan 09 '20 at 22:57
  • Thanks for the suggestion, but we can't get version locked because of a vendor API. I'll probably end up building a proxy to handle calls to the API using an older .net version. – user1142433 Jan 09 '20 at 23:37
  • You mean some sort of .net dll proxy or asp.net core 2.1 proxy? There is also an option to build a dedicated asp.net core 2.1 api service to work with cybersource and all other api services can use newer asp.net core versions. – Andrii Litvinov Jan 10 '20 at 06:18
  • 2
    Yes, I meant an api service proxy. WIll probably build it in .NET framework 4.x. :-/ – user1142433 Jan 10 '20 at 16:14
  • 1
    @user1142433 Interested to hear how you got on with this, as I'm currently facing a similar problem. If you did get something working, it would also make a great [self-answer](https://stackoverflow.com/help/self-answer) to this question. – Ian Kemp Jul 17 '20 at 14:40