Could not load file or assembly 'Microsoft.Extensions.Hosting, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'

longevity uyl 285 Reputation points
2023-12-22T08:38:19.89+00:00

I created a worker service based application project named WorkerService1. Visual Studio Community 2022 can build WorkerService1 project successfully. Than I copied WorkerService1.dll, WorkerService1.exe, and WorkerService1.runtimeconfig.json files to D:\WorkerService folder and running WorkerService1.exe from MS-DOS prompt. But it failed to run with the following error messages. Should I copy other files to D:\WorkerService folder?

Unhandled exception. System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Extensions.Hosting, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. 系統找不到指定的檔案。
File name: 'Microsoft.Extensions.Hosting, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'
   at Program.<Main>$(String[] args)

"

Developer technologies C#
{count} votes

Accepted answer
  1. Minxin Yu 13,501 Reputation points Microsoft External Staff
    2023-12-25T02:00:39.78+00:00

    Hi, longevity uyl

    The error means application cannot find DLL Microsoft.Extensions.Hosting.
    You need to put the DLLs required in the same folder as the exe.

    Best regards,

    Minxin Yu


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.