Multiple native dependencies are not copied to temporary storage when LoadInMemory=true
See original GitHub issueDescribe the bug
NuGet packages such as Confluent.SchemaRegistry.Serdes.Avro
that contains multiple native dependencies seems missing native libraries in temporary storage with enabled in-memory loading/unloading. Only the main library is being copied which cause DllNotFoundException
in the application.
To Reproduce
- Add
Confluent.SchemaRegistry.Serdes.Avro
to a library project - Publish the library with the following code executed from the entry point of the application:
var config = new ProducerConfig { BootstrapServers = "localhost:9092" };
using (var p = new ProducerBuilder<Null, string>(config).Build()) {
try {
var dr = await p.ProduceAsync("test-topic", new Message<Null, string> { Value="test" });
Console.WriteLine($"Delivered '{dr.Value}' to '{dr.TopicPartitionOffset}'");
}
catch (ProduceException<Null, string> e) {
Console.WriteLine($"Delivery failed: {e.Error.Reason}");
}
}
- Load the library with enabled in-memory loading/unloading:
var loader = PluginLoader.CreateFromAssemblyFile(assembly, config => { config.DefaultContext = assembliesContext; config.IsUnloadable = true; config.LoadInMemory = true; });
Expected behavior
All relevant native libraries from *.deps.json
should persist in temporary storage and loaded along with the main library.
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Copy native dependencies locally in a Visual Studio project
There are several ways to tell the VS to copy dlls to the destination folder: 1.Add the dll as a resource of the...
Read more >Description of how Word creates temporary files
This temporary document file is used to store all OLE objects that belong to unnamed documents, Undo, the Clipboard, and documents whose native...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks for the details. This looks to me like you’ve hit the edge of what we can reasonably support in the DotNetCorePlugins library and the “LoadInMemory” feature. I haven’t set up a full repro to verify my hunch, but here it is: it seems this callback is not invoked https://github.com/natemcmaster/DotNetCorePlugins/blob/452f8d306ef17c84c8b02b948e93eb95ef182be3/src/Plugins/Loader/ManagedLoadContext.cs#L210.
This could be because there are native <> native calls happening within the unmanaged dlls, so the AssemblyLoadContext is not called to help load. Or, it could because copying the native assembly to a new place breaks something the .NET runtime runtime.
Either way, it looks like a legit bug. I’m going to mark as “help wanted” since at this point this project is in maintenance mode and am not planning to tackle this bug myself.
Closing due to inactivity. If you are looking at this issue in the future and think it should be reopened, please make a commented here and mention natemcmaster so he sees the notification.