0

I'm currently trying to load an assembly on Runtime.

I'm using AssemblyLoadContext.Default.LoadFromAssemblyPath(path). Then, with the DependencyContext and the CompositeCompilationAssemblyResolver, I load unresolved dependcies using - Compile || Runtime - properties. Finally I fallback to load them directly from the Directory Path if they are yet not found.

However, dependices are still missing on some projects. Like the following

"Cannot find reference assembly 'Microsoft.AspNetCore.Mvc.Core.dll' file for package Microsoft.AspNetCore.Mvc.Core"

Even if it's found inside Compile or Runtime libs, TryResolveAssemblyPaths seems unable to locate them :/

Thanks for your help.

EDIT:

Well, After some research it appears than post 3.1 version of dotnet core framwork, some dependencies are directly loaded inside the SDK itself. Preventing you to load them manually through ICompilationAssemblyResolver or else.

So if you face that probleme with certain projects, apply same SDK on caller/callee (or import them). Microsoft.NET.Sdk.Web for example.

Doc: https://learn.microsoft.com/fr-fr/dotnet/core/project-sdk/overview

And: https://github.com/dotnet/cli/blob/master/Documentation/specs/runtime-configuration-file.md

EDIT 2:

I suggest you to read this issue on github: https://github.com/dotnet/runtime/issues/1050

Mr Vitek Karas answer to this problem in a more accurate manner.

1 Answer 1

2

what i am understand is you cannot load your assemply from path

so first get the path

 string path = HttpContext.Current.Server.MapPath("~/bin/dllname.dll");

then

 load =AssemblyLoadContext.Default.LoadFromAssemblyPath(path);
Sign up to request clarification or add additional context in comments.

1 Comment

Edit my post, the scope of the problem wasn't about path resolution, but really dependency resolve. Thanks you anyway :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.