Inspect dependencies for dynamically loaded library in .net core
Asked Answered
G

1

1

I'm trying to create plugin which uses some functions from external dll-s. Because I don't know which plugin will be used I would like to dynamically load:

  1. main asp.net core project which dynamically loads plugins like mailservice.dll using reflection.

  2. mailservice.dll library which exposes CheckMail() method (I use MimeKit as a IMAP helper).

Everything loads fine but when I invoke CheckMail() method I receive System.IO.FileNotFoundException: Could not load file or assembly 'MailKit, Version=1.16.0.0. So I put all dependencies for MimeKit extracted from release version and still nothing (46 files). When I install MimeKit package using nuget to my main asp.net project everything runs fine but obviously I don't want keep such dependency.

Is there any tool or technique to inspect which file is missing?

Glaudia answered 4/5, 2017 at 21:22 Comment(0)
A
4

To get assembly probing path from the dotnet core host,you can enable core host tracing.
If you are running from Visual Studio, Go to command prompt and location of your asp.net core main solution

set the environment variable with this command first

set COREHOST_TRACE=1

After that just run using dotnet run and you will get full details

To redirect the output to the text file,use redrection

dotnet run 2> log.txt

note: You need the '2>' redirection as dotnet host writes to the STDERR stream and not STDOUT.Your regular logging will be STDOUT .Hope this helps

Atherton answered 5/5, 2017 at 2:42 Comment(2)
thanks. I receive the same exception data. No path info or additional data.Glaudia
How can that work with IIS when doing an Owin project in .net core?Bakke

© 2022 - 2024 — McMap. All rights reserved.