Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

How to load multiple instances of a Dll in ASP.NET Core?

$
0
0

Hello. We have a piece of software that is used internally that has been turned into a Dll. It's written in C++. The desire was to run this on multiple platforms (Mac/Linux/Windows) as a service on the local network. There are 3 versions of this Dll: one for Mac, one for Linux and one for Windows. I've written a basic ASP.NET Core Web API that exposes the underlying functionality of the Dll via P/Invoke and a RESTful interface (my first), and I'm also in the process of writing a WPF client to pair with this new Web API service. The problem I have is that the Dll that was written is making heavy use of global data (arrays, variables, etc.) Therefore, if two or more clients are using the web API they will collide with the Dll's global state data. What I need is a way for each client to somehow load its own instance of the Dll.

After hunting around over the weekend I've discovered that this seems to be a pretty common problem and the standard "fix" is to dynamically make copies of the Dll file into a new file path and load it from there at runtime, for example:  http://stackoverflow.com/questions/15997037/loading-multiple-instance-of-dll-c-net  Is a anyone aware of a better way of getting multiple "instances" of a Dll into memory other than dynamically copying/loading from the file system, or is this still the only way to do this? If this is still the only way to do it will this hack also work for Mac and Linux environments?


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>