question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Windows - ms-vscode.csharp-1.2.2 - installation fails

See original GitHub issue

Environment data

dotnet --info output:

.NET Command Line Tools (1.0.0-preview3-003180)

Product Information:
 Version:            1.0.0-preview3-003180
 Commit SHA-1 hash:  d4193cd5c1

Runtime Environment:
 OS Name:     Windows
 OS Version:  6.3.9600
 OS Platform: Windows
 RID:         win81-x64

VS Code version: 1.3.1 C# Extension version: 1.2.2

Steps to reproduce

  1. Install VS Code & C# extension
  2. Close VS Code
  3. dotnet new
  4. code .

Expected behavior

The coreclr debugger installs itself

Actual behavior

Error message: Error while installing .NET Core Debugger.

coreclr-debug output

Creating C:\Users\neilhuiz\.vscode\extensions\ms-vscode.csharp-1.2.2\coreclr-debug\project.json
Telemetry is: Enabled

log  : Restoring packages for C:\Users\neilhuiz\.vscode\extensions\ms-vscode.csharp-1.2.2\coreclr-debug\project.json...

error: System.Linq 4.1.0 provides a compile-time reference assembly for System.Linq on .NETCoreApp,Version=v1.0, but there is no run-time assembly compatible with win7-x64.

error: System.Security.Cryptography.Algorithms 4.2.0 provides a compile-time reference assembly for System.Security.Cryptography.Algorithms on .NETCoreApp,Version=v1.0, but there is no run-time assembly compatible with win7-x64.
error: System.AppContext 4.1.0 provides a compile-time reference assembly for System.AppContext on .NETCoreApp,Version=v1.0, but there is no run-time assembly compatible with win7-x64.
error: System.Linq.Expressions 4.1.0 provides a compile-time reference assembly for System.Linq.Expressions on .NETCoreApp,Version=v1.0, but there is no run-time assembly compatible with win7-x64.
error: System.Security.Cryptography.X509Certificates 4.1.0 provides a compile-time reference assembly for System.Security.Cryptography.X509Certificates on .NETCoreApp,Version=v1.0, but there is no run-time assembly compatible with win7-x64.
error: System.Text.RegularExpressions 4.1.0 provides a compile-time reference assembly for System.Text.RegularExpressions on .NETCoreApp,Version=v1.0, but there is no run-time assembly compatible with win7-x64.
error: One or more packages are incompatible with .NETCoreApp,Version=v1.0 (win7-x64).

info : Committing restore...

log  : Lock file has not changed. Skipping lock file write. Path: C:\Users\neilhuiz\.vscode\extensions\ms-vscode.csharp-1.2.2\coreclr-debug\project.lock.json

log  : C:\Users\neilhuiz\.vscode\extensions\ms-vscode.csharp-1.2.2\coreclr-debug\project.json
log  : Restore failed in 2468ms.

Error: 
Errors in C:\Users\neilhuiz\.vscode\extensions\ms-vscode.csharp-1.2.2\coreclr-debug\project.json
    System.Linq 4.1.0 provides a compile-time reference assembly for System.Linq on .NETCoreApp,Version=v1.0, but there is no run-time assembly compatible with win7-x64.
    System.Security.Cryptography.Algorithms 4.2.0 provides a compile-time reference assembly for System.Security.Cryptography.Algorithms on .NETCoreApp,Version=v1.0, but there is no run-time assembly compatible with win7-x64.
    System.AppContext 4.1.0 provides a compile-time reference assembly for System.AppContext on .NETCoreApp,Version=v1.0, but there is no run-time assembly compatible with win7-x64.
    System.Linq.Expressions 4.1.0 provides a compile-time reference assembly for System.Linq.Expressions on .NETCoreApp,Version=v1.0, but there is no run-time assembly compatible with win7-x64.
    System.Security.Cryptography.X509Certificates 4.1.0 provides a compile-time reference assembly for System.Security.Cryptography.X509Certificates on .NETCoreApp,Version=v1.0, but there is no run-time assembly compatible with win7-x64.
    System.Text.RegularExpressions 4.1.0 provides a compile-time reference assembly for System.Text.RegularExpressions on .NETCoreApp,Version=v1.0, but there is no run-time assembly compatible with win7-x64.
    One or more packages are incompatible with .NETCoreApp,Version=v1.0 (win7-x64).


NuGet Config files used:
    C:\Users\neilhuiz\.vscode\extensions\ms-vscode.csharp-1.2.2\coreclr-debug\NuGet.config

Feeds used:
    https://api.nuget.org/v3/index.json

dotnet exited with error code 1

Mitigation/Possible solution

I tried working around the issue by manually editing the coreclr-debug project.json. I modified the frameworks node to look like:

  "frameworks": {
    "netcoreapp1.0": {
      "imports": [
        "netstandard1.6",
        "dnxcore50",
        "portable-net45+win8"
      ]
    }
  },

After this, dotnet restore succeeds, but the next time I start code, it just replaces the contents and fails again. I then hunted down the source of that file in %USERPROFILE%\.vscode\extensions\ms-vscode.csharp-1.2.2\out\coreclr-debug\install.js and modified the file at line 175 (DebugInstaller.prototype.createProjectJson()):

            frameworks: {
                "netcoreapp1.0": {
                    imports: [ "netstandard1.6", "dnxcore50", "portable-net45+win8"]
                }
            },

Upon restarting the vscode process, installation succeeded.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
neilhuizcommented, Jul 20, 2016

Root cause was an installation of the preview 1 SDK which was causing incorrect behavior in dotnet restore.

1reaction
neilhuizcommented, Jul 15, 2016

That got me somewhere. Here’s what appears to be the relevant output as seen on the console running OpenDebugAD7.exe:

>> accepted connection from client
Exception: System.AggregateException: One or more errors occurred. (Could not lo
ad file or assembly 'System.Reflection.Emit.Lightweight, Version=4.0.0.0, Cultur
e=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file spe
cified.) ---> System.IO.FileNotFoundException: Could not load file or assembly '
System.Reflection.Emit.Lightweight, Version=4.0.0.0, Culture=neutral, PublicKeyT
oken=b03f5f7f11d50a3a'. The system cannot find the file specified.
   at System.Linq.Expressions.Compiler.LambdaCompiler..ctor(AnalyzedTree tree, L
ambdaExpression lambda)
   at System.Linq.Expressions.Compiler.LambdaCompiler.Compile(LambdaExpression l
ambda)
   at Newtonsoft.Json.Utilities.ExpressionReflectionDelegateFactory.CreateParame
trizedConstructor(MethodBase method)
   at Newtonsoft.Json.Serialization.JsonObjectContract.set_ParametrizedConstruct
or(ConstructorInfo value)
   at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateObjectContract
(Type objectType)
   at Newtonsoft.Json.Serialization.DefaultContractResolver.ResolveContract(Type
 type)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(Jso
nReader reader, Type objectType, Boolean checkAdditionalContent)
   at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type
 objectType)
   at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, Jso
nSerializerSettings settings)
   at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSeriali
zerSettings settings)
   at OpenDebug.DispatcherProtocol.Dispatch(String req)
   at OpenDebug.DispatcherProtocol.ProcessData()
   at OpenDebug.DispatcherProtocol.<Start>d__24.MoveNext()
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceled
Exceptions)
   at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationTo
ken cancellationToken)
   at OpenDebug.Program.Dispatch(Stream inputStream, Stream outputStream)
   at OpenDebug.Program.<>c__DisplayClass5_0.<RunServer>b__0()
---> (Inner Exception #0) System.IO.FileNotFoundException: Could not load file o
r assembly 'System.Reflection.Emit.Lightweight, Version=4.0.0.0, Culture=neutral
, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
File name: 'System.Reflection.Emit.Lightweight, Version=4.0.0.0, Culture=neutral
, PublicKeyToken=b03f5f7f11d50a3a'
   at System.Linq.Expressions.Compiler.LambdaCompiler..ctor(AnalyzedTree tree, L
ambdaExpression lambda)
   at System.Linq.Expressions.Compiler.LambdaCompiler.Compile(LambdaExpression l
ambda)
   at Newtonsoft.Json.Utilities.ExpressionReflectionDelegateFactory.CreateParame
trizedConstructor(MethodBase method)
   at Newtonsoft.Json.Serialization.JsonObjectContract.set_ParametrizedConstruct
or(ConstructorInfo value)
   at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateObjectContract
(Type objectType)
   at Newtonsoft.Json.Serialization.DefaultContractResolver.ResolveContract(Type
 type)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(Jso
nReader reader, Type objectType, Boolean checkAdditionalContent)
   at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type
 objectType)
   at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, Jso
nSerializerSettings settings)
   at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSeriali
zerSettings settings)
   at OpenDebug.DispatcherProtocol.Dispatch(String req)
   at OpenDebug.DispatcherProtocol.ProcessData()
   at OpenDebug.DispatcherProtocol.<Start>d__24.MoveNext()<---

>> client connection closed

I verified that System.Reflection.Emit.Lightweight.dll is not present in the directory. I went back to %userprofile%\.vscode\extensions\ms-vscode.csharp-1.2.2\coreclr-debug and edited project.json to include "System.Reflection.Emit.Lightweight": "4.0.0" in the dependencies.

After that, I ran dotnet restore && dotnet publish -o debugAdapters. Finally, I restarted OpenDebugAD7.exe per your instructions and was able to start a debugging session. I also verified that I was also able to hit a breakpoint in my code!

I also returned my launch.json to its original state and verified that the debugger launches properly and attaches and all that jazz. If you all would like, I can resubmit my PR #576 to include a fix for this as well.

Read more comments on GitHub >

github_iconTop Results From Across the Web

VSCode can't detect the installation only when ...
The error seems to be that it can't detect visual studio code, even though it is certainly installed. This is exclusive to installing...
Read more >
Workaround for Omnisharp not downloading in VS Code issue
Open the download. · From the Omnisharp log under VS Code's output window you can pick up the file it tries to download...
Read more >
PSA: If your VS Code C# extension stopped working...
Click the gear button on C# extension and choose install another version. I use v.
Read more >
May 2016 (version 1.2) - Visual Studio Code
To fix several performance and Git integration issues, we're releasing a 1.2.1 recovery build. You can view the resolved issues here. Downloads: Windows...
Read more >
How to Run C# in Visual Studio Code on Windows 10 2022
Run csharp and .NET program in visual studio code on windows Hey, guys in this video I'm going to show you how you...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found