1

I have a .NET Core web api project (further in text - the api), and also I have a .NET Framework library (the library). I want have an ability to call the library from the api. How can I reach this? I googled for a while, but has found no useful article or example.

I MUST implement the library on .NET Framework, because it uses some unique and alternativeless references.

2
  • What happened if you simply added a reference to the assembly? Commented May 24, 2020 at 15:06
  • @LasseV.Karlsen It is built and even works, but I have an exception in itextsharp when creating PDF stamper. Considering that the call and parameters are the same, I think that it can be the reference issue Commented May 24, 2020 at 15:12

1 Answer 1

2

I MUST implement the library on .NET Framework, because it uses some unique and alternativeless references.

If that's the case, then you must host it in a process that loads the .NET Framework Common Language Runtime.

And the only interop between .NET Framework CLR and .NET Core CLR is the normal IPC mechanisms. You can't use .NET Remoting or MarshalByRefObjects like you could across AppDomains in .NET Framework.

Since you're already hosting a web API, the natural thing is probably to host a separate web API on the .NET Framework to host your library. Alternatively you could write a .NET Framework COM component to wrap your library and access it from COM Interop from .NET Core on Windows. And, of course, you can always just build a .NET Framework .exe and launch it from .NET Core with Process.Start.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.