question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Multiple native dependencies are not copied to temporary storage when LoadInMemory=true

See original GitHub issue

Describe 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

  1. Add Confluent.SchemaRegistry.Serdes.Avro to a library project
  2. 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}");
	}
}
  1. 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:closed
  • Created 2 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
natemcmastercommented, Jun 13, 2021

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.

0reactions
github-actions[bot]commented, Jun 28, 2022

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found