came across several post but doesn't seem to be able to find a definite answer as to how do one integrate ZeroMQ and Unity without the use of a wrapper/dll.
Wanting to use a Pub/Sub method, so it would be nice if someone is able to assist on this as well.
P/S using VS Code.
Tried copying the entirety of https://github.com/zeromq/netmq/tree/master/src/NetMQ and pasting it into Unity's Asset/Plugin but unable to compile. See Image
Also saw that someone said to use the lib folder in clrzmq and paste it inside netmq, but still unable to compile.
The standard way to use libraries is to import them using nuget. This ensures any other dependencies are included.
I have not used unity3D, but there seem to be a asset to import nuget packages. See this post for more info.
From the NetMQ homepage:
NetMQ is a 100% native C# port of ZeroMQ
This means you do not need clrzmq or any other native library. You still need the dll for NetMQ, but .net dlls are typically easier to include and use than wrappers around native libraries.
Note that NetMQ uses LGPL license, that means you can use the dll for the library. But if you actually include the source code that would mean your whole game would also need to be licensed under LGPL.
Related
I want to write a small .Net MAUI application which makes use of a C# SDK NuGet Package (implementing Hyperledger Anoncreds).
When running the App on Android (emulator or device) most of the SDK method calls work, but certain calls still throw a DllNotFoundException without any indication of which Dll is actually missing.
After I did some reading on the SDK, I was able to add some .so dependencies to the MAUI project, but apparently there are still some missing.
I already tried reading through the SDK source code and some of the Rust code it wraps to get hunch of what could possibly be missing. But even wading through the cargo.toml files only show me the crates and not any actually libraries.
Android tools like "APK Analyzer" provide a lot of usefull information, but no dependency overview and the "Dependency Walker" tool only analyzes Windows-built binaries which differs from the actual Android environment.
How do I find the missing dependency indicated by the Exception? Is there a tool like "Dependency Walker" for Android APKs?
Edit: Fixed some typos and added more Info.
After a quick google search for an equivalent of ldd on Android I found this:
ndk-depends which should be shipped with Android NDK. I would try and use that on the .so files that you use and include with your project.
EDIT: Here is a link to the manual: ndk-depends
Hope it helps!
During runtime, I want to download the latest DLL from the NuGet library using .NET Core and load it into the container.
I am looking at a scenario when a set of dependencies has been changed and new package versions are released to nuget.org, after which I will have to download the latest packages and run some tests. Each time the application will verify if it has the latest package version and, if necessary, download and dynamically load the new assembly without the application stopping.
I'll start off saying that this doesn't sound like a good idea. You didn't explain the scenario about why you want to do this, so we have no way of suggesting better approaches. If it's a web application that you don't want to have downtime for, a better approach might be to have a load balancer and when you release a new version of your web app, to configure the load balancer to send all new requests to the new contains/version while the existing connections on the old version drain.
If your app is a queue listener, you don't need hot-loading at all. Just have an app which creates a pull request on your source code to update nuget package version numbers when they're available, have the CI automatically build the change and if tests pass you can automate approving/merging the PR then your CD can automatically deploy and decommission the previous version. This would be less risky than automatically loading new versions since you risk the new version having bugs or not being binary compatible and now your app is going to crash.
Anyway, if you really do have a good reason to hot-reload assemblies, on .NET Core you'll need to use AssemblyLoadContext. However, it's such an unusual case to need this, that I can't find any realistic examples on how to use it. All the "examples" I've seen use AssemblyLoadContext.Default which I assume is equivilent to using a single context and therefore won't let you load different versions of the same assembly. So, if you want to go down this path, you're probably going to have to figure it out yourself. Lots of trial and error, debugging and possibly reading the coreclr source code. As some commenters to your question mentioned, you'll also need to handle the case that an assembly was compiled against one version of a dependency, but you're now going to load a different version. In the .NET Framework is uses something called Assembly Binding Redirect. The way most people use this is with an app.config or web.config file, but that won't work for you since it will change at runtime. I'm sure there's an API to deal with it programatically, which you'll also need to figure out. I'm not sure how/if binding redirects are different in .NET Core compared to the .NET Framework, so that's yet another thing you'll need to figure out, but I'm sure a couple of good searches on google will give you an answer to that.
Once you get assembly hot reloading working, you can either read the NuGet server API and implement your own client, or you can use the NuGet client SDK. But the NuGet Client team's primary focus are the tools (Visual Studio integration, dotnet cli, nuget.exe), they just publish the packages for convenience (plus as a way to share the libraries with dotnet cli and mono), so there are no docs on using the SDK. Also note that while the NuGet client team tries not to break the packages binary API, it's a secondary concern when needing to implement features and bug fixes for the tools. The NuGet client SDK track Visual Studio version number, it doesn't use semantic versioning, so when you try to update to newer NuGet client packages, you might find you need to change your code when you otherwise might not expect. It's pretty rare, but I generally recommend the "ports and adapters" pattern, and this is an excellent example of when it's particularly useful. At least with the NuGet client packages, there are blog posts from people who figured it out and shared how they did whatever they needed. Otherwise since NuGet itself is opensource, you can look though NuGet's code to see how it uses the packages internally, and use that as a guide to help you figure out what you want to do. If you go down this path you'll need to do most of what the nuget tools do:
Query a NuGet feed to find what versions of a package are available, then choose which version you want to use and check if that version is already downloaded.
Download and extract the package.
Asset selection. Particularly when a package has libraries for multiple TFMs, you need to know which one to use based on your project's TFM
The NuGet client at this stage would either write the project.assets.json file, used by the .NET SDK, or edit the packages.config and csproj files, depending if the project uses PackageReference or packages.config. In your case this is where you integrate with assembly hot-reload.
Note that in the general case, the process above, or depending on how you implement it a single step, could be recursive because a package can have dependencies. So, the dependencies also need to be retrieved, but a package can have different dependencies depending on which TFM is selected, so you need to figure out do you want to download all dependencies, even ones that will never be used after asset selection, or do you want to do asset selection first to minimise the packages that you download. Also when multiple packages have a dependency on different versions of a single package, you need to make a decision about which version of the package you want to use.
So, that's the high level algorithm you'll need to implement. As I mentioned, most of this doesn't have API docs with examples on exactly how to implement it, and very few, if any, examples exist on the internet. Like I wrote in the first paragraph, I don't think this is a good idea. It's probably easier to automate your CI/CD pipelines, and if necessary automate changes to a load balancer's configuration, rather than making such a complex app. Sometimes orchestrating a bunch of simple apps is easier than making a complex app.
I developed a cross-platform SDK in C#, therefore I have this PCL libraries with profiles including .Net45 and .Net40.
To implement an automation scriptable tool, I was thinking to reference the library from some scripting language like powershell (any other/better option?) but not sure how to do that or if it is possible at all? Especially considering that all the SDK calls are asynchronous.
I can't see any reason why this isnt possible. Just include the dll using Add-Type and use it.
I'm trying to add the Libspotify SDK to a test solution. However, I got the following error:
Now, I tried following the first answer of this question. However, all I got was:
The package of the library is structured in the following way:
Additionaly, my project is targeted to .NET Framework 4.0
And the configuration is done as follows:
What can I do to add this library?
EDIT:
Also, I found this link where someone explains that it need to be copied manually into the project output directory. I tried putting the .dll there, but I guess I have to modify something else to make it work. Any ideas?
The libspotify.dll you are trying to access is a Win32 C library, not a C# (.NET) assembly. As such, you can only use it through interop.
You don't have to do this yourself (judging by your question I'm assuming you have no previous experience with the techniques involved), you can use a ready-made solution like libspotify.NET.
I have an issue with creating an easy solution for my build system, based on mono.
Current situation is that I keep my referenced libraries inside the git repository, which is not good, for many obvious reasons.
What I want to achieve is something like what NuGet provides - automatically download dlls from the Web, put them in some directory and forget about them.
I want to do this at build time, so it would not require any additional actions with downloading libraries etc. The best option would be an msbuild (xbuild on mono) task, but I want it to be system independent, so the popular one, executing NuGet.exe, is out of question (consider parallel mono installations, etc.).
I've tried Pepita project, but it's... wrong. No, really, it is, it has too many design mistakes to be easy to use or repair. To make a proper configuration would require a serious rewrite of the whole project.
What I would love is a library, that would employ NuGet.Core library and be available as a task. If such a lib is not there, I could use any solution, that would download a nuget package and unpack it to a directory specified in .csproj.
Even better, it would be nice if such a library could resolve dependencies without specifying them explicitly in packages.config (or similar) file, e.g. if I want to include Castle.Windsor I don't want to include Castle.Core in my config file.
I know about the OpenWrap project (with NuGet Gallery), it looks promising, but I can't find the solution where I would just put a constant set of libraries in my repo once, modify csproj files, some configs and have it done.
I can tell you that OpenWrap at the core has everything built-in to do what you want. Everything you can do with the openwrap-shell is also available to be called from msbuild. So, it seems to me that you would just need to add a before build hook to call out to openwrap to perform an "update-wrap". Several months back I actually looked into doing something similar. AFAIR I actually wrote an msbuild script to call openwrap tasks, but didn't really hook them into the normal build process.
I don't know exactly what you mean with "put a constant set of libraries in your repo once"? For OpenWrap, all you need to do is maintain the "openwrap descriptor" for your project. That file contains all direct dependencies of your project (with or without restrictions on version numbers). (Indirect dependencies are pulled in automatically) Are you wondering about how you get started when you have a bunch of binary dlls to start with? I can tell you what I did. Basically, I do not use any NuGet packages, I created OpenWrap packages for everything. I also created OpenWrap packages for all our binary dependencies (some of which are open-source). This is really super simple: you fill in correct dependencies in the OpenWrap descriptor and specify that the package must only contain the given dlls. We had a bunch of binary dependencies, but once you start packaging them, it's definitely not that much work.
If you want to see an example, you can check this one:
http://code.google.com/p/ppwcode/source/browse/dotnet/External/Apache.Log4Net/trunk/Apache.Log4Net.wrapdesc
That is all you have to do to package your binary dependencies. This is a package I created and we currently use it in the company where I work. I know Log4Net is probably available as a NuGet package, and I could probably use that. The advantage of creating those binary packages myself, is that I have full control over the packages, over the version numbering of the packages, over how a big project is split over several smaller packages and so on.
As an OpenWrap repo, you can use a folder on your local filesystem, or a folder on a network share. What we use, is actually a webdav repository that we mount locally on a drive (using Windows 7). This works fine for us and also allows us to specify who has read and write access to the repository.
You mention mono.... well, that might be a problem: the currently released version of OpenWrap (2.0.2) does not run on mono AFAIK. But the good news is that Sebastien Lambla has been working hard to get OpenWrap to run on mono+xbuild for the new version that is going to be released very soon: 2.0.3. No alpha/beta builds available yet, but you can build from git. (In that case you would need to build both openwrap-shell and openwrap). Sebastien Lambla, who created OpenWrap, normally keeps an eye on questions on StackOverflow and will probably be able to give you a more complete answer on the mono status.
Btw, where I work, we are using OpenWrap already for over a year. Back then we compared both NuGet and OpenWrap, and at that moment OpenWrap was way way way ahead of NuGet. Basically, to me, NuGet was not a tool for dependency management, but a tool to assist you in Visual Studio to pull in binary dependencies from a remote server (meaning: copy dll from remote server to local folder and add reference to local dll in project file). In the mean time, NuGet has been playing catch-up with OpenWrap and has added functionality that already existed in OpenWrap. There are in my opinion only 2 things that NuGet has over OpenWrap and that is integration in Visual Studio (aka overview of remotely available packages and click-click-click adding of packages) and the fact that it is maintained by Microsoft people (AFAIK). Both things are just political: it's easier to convince people with a pretty interface and microsoft support. Personally, however, I think that OpenWrap is technically superior and I think it's really a pity that it doesn't get the attention that it deserves.