Sdk: The library 'hostpolicy.dll' not found after build

Created on 1 Mar 2017  路  4Comments  路  Source: dotnet/sdk

Steps to reproduce

  1. Clone https://github.com/OSAMES/osames-orm
  2. Create new .NET Project where you want
  3. In new .NET Project, copy files and directory from osames-orm directory :

    • Config directory
    • Configuration directory
    • DbTools directory
    • Logging directory
    • Resources directory
    • Utilities directory
    • all .cs files in root directory
  4. Create project.json with this:
    ```{
    "version": "1.0.0-*",
    "buildOptions": {
    "debugType": "portable",
    "emitEntryPoint": false
    },
    "dependencies": {
    "System.Data.Common": "4.3.0",
    "System.Xml.XPath": "4.3.0",
    "System.Configuration.Abstractions": "2.0.2.3"
    },
    "frameworks": {
    "net46": {
    "frameworkAssemblies": {
    "System.Windows.Forms": {},
    "System.Web": {}
    }
    }
    }
    }

5. adapt the program path launch.json file :

{
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (console)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceRoot}\bin\Debug\net46\orm.net.dll",
"args": [],
"cwd": "${workspaceRoot}",
"externalConsole": false,
"stopAtEntry": false,
"internalConsoleOptions": "openOnSessionStart"
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command.pickProcess}"
}
]
}

6. Make dotnet restore

## Expected  behavior
Able to debug the dll in Visual Studio Code
## Actual behavior
A fatal error was encountered. The library 'hostpolicy.dll' required to execute the application was not found in 'f:\Developpements\orm.net\bin\Debug\net46'.

The program 'f:\Developpements\orm.net\bin\Debug\net46\orm.net.dll' has exited with code -2147450749 (0x80008083).

## Environment data
`dotnet --info` output:
.NET Command Line Tools (1.0.0-preview2-003156)

Product Information:
 Version:            1.0.0-preview2-003156
 Commit SHA-1 hash:  33dabee5d8

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.14393
 OS Platform: Windows
 RID:         win10-x64

## Tasks.json

{
"version": "0.1.0",
"command": "dotnet",
"isShellCommand": true,
"args": [],
"tasks": [
{
"taskName": "build",
"args": [
"${workspaceRoot}\project.json"
],
"isBuildCommand": true,
"problemMatcher": "$msCompile"
}
]
}
```

Notes:

If I copy the missing dll, I have this message :
Could not resolve CoreCLR path. For more details, enable tracing by setting COREHOST_TRACE environment variable to 1

Most helpful comment

Alas! It's reproduced in VS 2017 Enterprise with .cproj

All 4 comments

@Xarkam it looks like the issue here is that you're building a desktop [net46] project but trying to debug it as a .NET Core project. @DustinCampbell may be able to help with enabling debugging for that project!

Also, it seems you are using project.json based tooling. Please, migrate your project to csproj and use the 1.0 version of the tooling.

We are no longer actively support project.json.

If this still repros with the new tooling, then please re-activate and if possible share your csproj.

Alas! It's reproduced in VS 2017 Enterprise with .cproj

This still happens with VS2017 5.6 and csproj

Was this page helpful?
0 / 5 - 0 ratings