cairabbit
cairabbit

Reputation: 65

VS 2014 CTP doesn't recognize namespaces in mscorlib

I installed vs 2014 ctp 3 in my windows 8.1 virtual machine. And try to create a vnext library. As I add using statement in my codes:

using System.Diagnostics;  
using System.Threading.Tasks;

public Task Log(LogLevel level, IFormatProvider formatProvider, string message, params object[] args)  
{
    return Task.Run(() =>  
    {  
        if (IsLogLevelEnabled(level))  
        {  
            string category = Enum.GetName(typeof(LogLevel), level);  
            string info = string.Format(message, args);  
            Debugger.Log((int)level, category, info);  
        }  
    });  
}  

There did come the code intelligence by "Debugger.Log", which may mean that the vs find the references in mscorlib. And if I press "F12", vs will navigate to the codes of Debugger in mscorlib.dll. However, when I try to build the projects, it always throws:

The name "Debugger" doen't in the current context.

I tried to add reference in project.json, however, there is no "System.Diagnostics" for reference. If I wrote "System.Diagnostics": "" in project.json, there comes a warning in the references of project.

What should I do? Thank you in advance.

Upvotes: 4

Views: 283

Answers (1)

AndersNS
AndersNS

Reputation: 1607

If you have the default project.json given by the CTP3 templates you have the k10 (CoreCLR) target framework defined, as well as good old net451. The Debugger class does not have that method (don't ask me why) in the k10 target framework, and thus will not build. Remove the k10 target from your project.json and it will build, but now only towards net451.

Your project always builds towards net451 though, VS14 does not give you a good way to see which target framework is failing. Hopefully they add this functionality soon.

This project.json builds:

{
    "dependencies": {
        "System.Diagnostics": "",
        "System.Threading": ""
    },

    "frameworks" : {
        "net451" : { 
            "dependencies": {
            }
        }
    }
}

This does not build:

{
    "dependencies": {
        "System.Diagnostics": "",
        "System.Threading": ""
    },

    "frameworks" : {
        "net451" : { 
            "dependencies": {
            }
        },
        "k10" : { 
            "dependencies": {
                "System.Runtime": "4.0.20.0"
            }
        }
    }
}

Upvotes: 1

Related Questions