111 questions
0
votes
1
answer
77
views
LoadFrom doesn't load from Module: C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App
I'm trying to load DLLs from my app do some investigation. I use LoadFrom to load them like this
Assembly.LoadFrom("C:/Dev/MyApp/My.Dll");
and it fails with
System.Reflection....
1
vote
1
answer
599
views
Why is Microsoft.Data.SqlClient throwing TypeInitializationException when loading Microsoft.Identity.Client at runtime?
I have an Entity Framework 6 model (code-first, with migrations enabled and auto-migrations disabled) in a class library that targets .NET 4.8 and .NET Standard 2.1 (AnyCPU). This is an SDK-style ....
0
votes
1
answer
628
views
.NET 8 app not running due to missing PresentationFramework assembly (non-reproducible)
I have a .NET 8.0.401 app which uses the following dependencies:
>dotnet list xxx.csproj package
Project 'xxx' has the following package references
[net6.0-windows7.0]:
Top-level Package ...
0
votes
1
answer
220
views
How to avoid DLL not found error on T4 template?
I created a T4 template to generate a partial class.
It references one of my DLLs:
<#@ assembly name="$(ProjectDir)..\Base\bin\Debug\net8.0\Base.dll" #>
If the DLL doesn't exist, my ...
2
votes
0
answers
199
views
"System.IO.FileNotFoundException: Could not load file or assembly" exception at registration of service using types from dynamically loaded assembly
App overview
I am working on WPF/MVVM application, which is sort of an expansion of functionality for another desktop application (let us call it Application X).
I am trying to use layered approach ...
0
votes
1
answer
1k
views
How to override dependency version of a nuget package
I have a .netstandard2.0 project, let's say it is called common, which is using System.Configuration.ConfigurationManager 5.0.0 and log4net 2.0.15 from nuget.org.
This common project is used by ...
1
vote
0
answers
81
views
Access Violation from R2R (ready-to-run) assembly when using GetTypes() from a thread in Net Core (Net7)
I am in a thread where I am using
AssemblyLoadContext.Default.Assemblies
to retrieve the loaded assemblies and call GetTypes() on them.
In the list of assemblies there is also PresentationFramework ...
1
vote
0
answers
179
views
Cannot read config file in dependency injected plugin
I have a service with a plugin architecture that requests plugins from a web api and extracts them into their own directory (Plugins/plugin_id). Each plugin is loaded into a custom PluginLoadContext, ...
2
votes
0
answers
225
views
Loading DLLs built for different runtime versions in .NET Core AssemblyLoadContext
We use .NET 6's AssemblyLoadContext to setup a plugin system.
Is it, for example, possible to load a .NET Core 3 or a .NET 5 dll in an AssemblyLoadContext in a process that was built for .NET 6? And ...
0
votes
0
answers
112
views
Load assembly interface without sharing common library
I was wondering if the common library needs to be shared between assemblyA and assemblyB.
What needs to be achieved is loading assemblyA inside assemblyB code and cast the interface as below after ...
2
votes
1
answer
383
views
Why does AppDomain still have a reference to a dynamically loaded assembly after the unload event fires?
This is a netcore question, not a NETFX question.
This workup demonstrates the behaviour. You will need to supply an assembly for it to load and make the name in the code match the name in the file ...
0
votes
1
answer
695
views
AssemblyLoadContext loading and unloading get different results in different functions
This is code from microsoft docs. Please note the comments in the code
class TestAssemblyLoadContext : AssemblyLoadContext
{
private AssemblyDependencyResolver _resolver;
public ...
0
votes
1
answer
267
views
Is `GetReferencedAssemblies` a subset of `AppDomain.CurrentDomain.GetAssemblies()`?
I want to test some reflection code I've written.
There's an edge case that would occur if the ReferencedAssemblies were ever not already loaded into the AppDomain, i.e. if the following expression ...
1
vote
0
answers
635
views
AssemblyLoadContext.Unload does not unload a Wpf Library
I am writing here the same issue posted on Github since I don't see much traffic there recently.
.NET Core Version: 3.1.9 and .Net 5
Windows version: 10.0.18363
Does the bug reproduce also in WPF for ...
2
votes
1
answer
469
views
Binding redirect not effective in VSPackage/VSIX
Main Question
I'm using VS2017 (15.9.25) to develop a VSIX VSPackage.
The package uses the MySqlConnector 1.0.0 NuGet package, which in turn depends on System.Memory 4.5.4 NuGet package which includes ...
3
votes
1
answer
2k
views
AssemblyLoadContext and Assembly.LoadFrom(path)
GetCustomAttribute cannot find attribute on an assembly loaded via "Assembly.LoadFrom(path)" in custom AssemblyLoadContext.
The load flow:
Main app has custom AssemblyLoadContext
Custom ...
1
vote
1
answer
3k
views
AssemblyLoadContext.Default in netcore 3.1 resolve the plugin type but can't excute its instance when the plugin use transitive dependency
I have a console application in netcoreapp3.1 that use a netstandard2.0 plugin.
The plugin reference a class library and implement an interface
All dll dependencies are in the the plugin folder and ...
3
votes
1
answer
4k
views
What is the value of AssemblyLoadContext.Unload() in .NET Core in comparison with regular garbage collection?
.NET Core 3.0 introduced collectible AssemblyLoadContext, which allows to call Unload() method to unload assemblies loaded inside the context.
As per documentation (https://learn.microsoft.com/en-us/...
5
votes
1
answer
2k
views
Does AssemblyLoadContext isolate static variables?
Announcement tells us:
Assembly unloadability is a new capability of AssemblyLoadContext. This new feature is largely transparent from an API perspective, exposed with just a few new APIs. It ...
4
votes
2
answers
2k
views
Resolving a TypeReference to a TypeDefinition in Mono.Cecil fails with Assembly Resolution Error
I'm trying to get a Mono.Cecil TypeDefinition from a .NET type and not having any luck.
I'm using code like this:
var type = typeof(MarkdownMonster.AppConfiguration);
var a = AssemblyDefinition....
8
votes
2
answers
2k
views
How to load an assembly from byte array into a non-default AppDomain without accessing the app directory?
I have an in-memory assembly MyAssembly (class library) that is used in my main assembly MyApp.exe:
byte[] assemblyData = GetAssemblyDataFromSomewhere();
(For testing, the ...
3
votes
1
answer
1k
views
T4 templates failing because they try to load assemblies from visual studio common directory
We've got a project that uses the Entity Framework to CRUD data to/from the database.
I'm now trying to write a T4 template that uses the EF access to generate testdata in code form like var users = ...
0
votes
1
answer
372
views
Pre-loading assembly doesn't seem to work
I am writing a test to check that all the controllers in my Unity config are registered correctly. As part of my test, I use reflection to check for all the non-abstract classes that inherit from ...
2
votes
0
answers
890
views
Dependency problem deploying .NET Core application to Server 2012
I'm developing a web application in C#, Visual Studio 15.8.4, using Microsoft.AspNetCore.All 2.1.4. I am trying to deploy on Windows Server 2012. I am experiencing the following error on the server ...
1
vote
0
answers
191
views
How to load assembly into default load context without adding into GAC?
I tried to load the assembly in Assembly Resolve event. Also I got the hook up and loaded the assembly in the app domain using Assembly.LoadFrom.
But when I access a method from the assembly in the ...