Control Freak
Control Freak

Reputation: 13233

Knowing what you should be using in WebMatrix

When a new package is downloaded from NuGet, how is someone supposed to know what to enter in for @using ...?

For example I'm trying to use Json.NET I downloaded it to the project off NuGet, now I'm trying to run JsonConvert.SerializeObject(x); and it says error:

The name 'JsonConvert' does not exist in the current context

I found it online looking up the error, so I know it's using Newtonsoft.Json;, but how is one supposed to know this for in the future?

Upvotes: 1

Views: 87

Answers (2)

James
James

Reputation: 82096

I usually use the Resolve option from the Visual Studio context menu for namespace resolution

enter image description here

Upvotes: 2

Afzaal Ahmad Zeeshan
Afzaal Ahmad Zeeshan

Reputation: 15860

In the WebMatrix, when you open a new project, inside the root folder, there is a folder called /bin/ where all of your dll files and these type of files that you add from the NuGet package are saved. ASP.NET saves its files there, and each time you add a new package it is saved in this location and each namespace is called from the bin folder.

You can look for each of the library file added to your web application by opening the bin folder and then looking into it. You can easily find out, what name of the file you might be looking for, for example

using Newtonsoft.Json;

Newtonsoft.Json.dll is the file's name this time inside the bin folder. Next time a similar name would be there, you can look for them and then call their name.

You should know that this is the place where you call the Namespaces to be resolved in your project. As James has already provided a solution for Visual Studio, WebMatrix thing I have told you. There is no method that would automatically write the package's location. You will have to call it yourself. To find out the list of the items that you can include, you can find them inside the bin folder of your root folder.

Upvotes: 1

Related Questions