sdk icon indicating copy to clipboard operation
sdk copied to clipboard

Could not load file or assembly 'dotnet.EXE.dll'

Open AlexeyRokhin opened this issue 10 years ago • 14 comments

I downloaded net cli binaries and executed dotnet restore within folder which contains asp.net core project. Some packages were restored and several errors about incompativlity were displayed. Then I tried execute dotnet new within empty directory and got error Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'dotnet.EXE.dll' or one of its dependencies. I tried to uninstall and reinstall (and also repair) but error still occurs.

version 1.0.0.001540

AlexeyRokhin avatar Feb 26 '16 12:02 AlexeyRokhin

@AlexeyRokhin which OS? Can you share your project.json?

thesmithee avatar Feb 26 '16 14:02 thesmithee

@blackdwarf Windows 8.1 Professional x64. Sorry, it was console (not asp.net) project with following json:

{
  "version": "1.0.0-*",
  "description": "CoreConsoleApp1 Console Application",
  "authors": [ "a.rokhin" ],
  "tags": [ "" ],
  "projectUrl": "",
  "licenseUrl": "",

  "compilationOptions": {
    "emitEntryPoint": true
  },

  "dependencies": {
  },

  "commands": {
    "CoreConsoleApp1": "CoreConsoleApp1"
  },

  "frameworks": {
    "dnx451": { },
    "dnxcore50": {
      "dependencies": {
        "System.Console": "4.0.0-beta-23516",
        "EntityFramework.SqlServer": "7.0.0-beta8"
      }
    }
  }
}

But now I got error when I execute any dotnet xxx command within both console project directory and empty directory.

AlexeyRokhin avatar Feb 26 '16 15:02 AlexeyRokhin

@AlexeyRokhin does running simply dotnet do anything on the system or does it not work?

thesmithee avatar Feb 26 '16 16:02 thesmithee

@blackdwarf dotnet without parameters causes the same exception.

AlexeyRokhin avatar Feb 29 '16 07:02 AlexeyRokhin

@AlexeyRokhin can you try to upgrade to latest bits and see if it repros? It is a strange thing...

thesmithee avatar Feb 29 '16 14:02 thesmithee

@blackdwarf Same exception. Here the xml from event viewer: <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event"> <System> <Provider Name="Application Error" /> <EventID Qualifiers="0">1000</EventID> <Level>2</Level> <Task>100</Task> <Keywords>0x80000000000000</Keywords> <TimeCreated SystemTime="2016-02-29T14:38:51.000000000Z" /> <EventRecordID>544714</EventRecordID> <Channel>Application</Channel> <Computer>skipped</Computer> <Security /> </System> <EventData> <Data>dotnet.EXE</Data> <Data>0.0.0.0</Data> <Data>56d364f0</Data> <Data>KERNELBASE.dll</Data> <Data>6.3.9600.18202</Data> <Data>569e7eb1</Data> <Data>e0434352</Data> <Data>0000000000008a5c</Data> <Data>2750</Data> <Data>01d172fee886b0da</Data> <Data>C:\Program Files\dotnet\bin\dotnet.EXE</Data> <Data>C:\Windows\system32\KERNELBASE.dll</Data> <Data>263756c5-def2-11e5-82a5-d850e64e09a1</Data> <Data /> <Data /> </EventData> </Event>

Here call stack from attached debugger (VS 2015)

coreclr.dll!00007ffe31eb679c()
coreclr.dll!00007ffe31eba98e()
coreclr.dll!00007ffe31e73397()
coreclr.dll!00007ffe31e72bbb()
hostpolicy.dll!00007ffe524f66c4()
hostpolicy.dll!00007ffe524f6997()
dotnet.exe!00007ff7c93718a1()
dotnet.exe!00007ff7c939b718()```

AlexeyRokhin avatar Feb 29 '16 14:02 AlexeyRokhin

@blackdwarf , I found workaround for issue: call dotnet.exe instead of dotnet Very strange.

AlexeyRokhin avatar Mar 02 '16 07:03 AlexeyRokhin

strange indeed.

Can you where dotnet and where dotnet.exe and see if this yields anything interesting? I wonder if there's something funny on the PATH.

TheRealPiotrP avatar Mar 03 '16 05:03 TheRealPiotrP

btw, in PowerShell you need to call where.exe

TheRealPiotrP avatar Mar 03 '16 05:03 TheRealPiotrP

@piotrpMSFT where dotnet and where dotnet.exe returns the same path. Thank you for your note about powershell! Usually I'm using Far Manager instead of cmd.exe. I found that only Far Manager causes this exception. cmd.exe and powershell is OK.

AlexeyRokhin avatar Mar 03 '16 06:03 AlexeyRokhin

ok, I think I get it. If you could, do one more experiment in Far Manager @AlexeyRokhin: call dotnet.EXE [note capitalization on .EXE]. Does it fail in the same way as dotnet[without .exe]?

TheRealPiotrP avatar Mar 03 '16 07:03 TheRealPiotrP

dotnet.EXE fails exactly the same way as dotnet.

AlexeyRokhin avatar Mar 03 '16 07:03 AlexeyRokhin

@schellap, I believe this to be a bug in CoreHost. Specifically, I expect that when Far Manager tries to resolve a file without extension then it grabs potential file extensions from PATHEXT and appends them to the provided file name. PATHEXT lists file extensions in upper case so it ends up looking for dotnet.EXE. This invokes dotnet.exe as dotnet.EXE, which is the string passed in to CoreHost. Now the bug: on Windows, once CoreHost determines that it's in CoreConsole mode it tries to determine its own name. If it's name ends in .exe then it trims the last four characters, appends .dll, and looks for an implementation dll with the same name. Otherwise, it appends .dll to the full string and looks for an implementation with that name. The problem is:

    if (ends_with(result, _X(".exe")))

This is a case-sensitive comparison. So when Far Manager [or any other tool building a valid name for the exe] capitalizes the suffix, the comparison fails and we end up in the scenario outlined in this bug.

TheRealPiotrP avatar Mar 03 '16 07:03 TheRealPiotrP

Moving the bug to RTM milestone.

TheRealPiotrP avatar Mar 03 '16 07:03 TheRealPiotrP