dergroncki
dergroncki

Reputation: 798

Add a reference (.Net-Dll) to an ASP.NET 5 / MVC 6 project at compile time

I am using Visual Studio Community 2015 RC. I have created an ASP.NET 5 / MVC 6 project.

Now I want to add a (.NET) DLL to the project but if I open the dialog “Add Reference...” I am not able to browse any folders outside the solution. The browse button is missing.

Is there any other way to add a reference to the project at compile time?

A class library (as a NuGet package) is not a solution because here is the same problem. If I create, say, a WPF application the browse button is available.

Upvotes: 2

Views: 10042

Answers (3)

Deeps
Deeps

Reputation: 368

In order to Add additional dll or third party dll in MVC6 please follow below steps.

  1. you may create nuget package of the dll by "Nuget Package Explorer".
  2. Now you need to add a location for the nuget package (In order for Best practices we should create a folder at solution location). In Visual Studio Go To Tools > Options > Nuget Package Manager > Package Sources > click on "+" button > select location by browsing and click update > press ok button.
  3. Next, in Solution explorer right click on reference > Manage Nuget Packages > select Package source which you have created earlier and install it.

Now you will be able to find it under DNX 4.5.1

Upvotes: 4

dergroncki
dergroncki

Reputation: 798

The following procedure worked for me:

Add a new project for creating a (classic) C# class library (.dll) to the solution.

Add the external DLLs to the class library project by right clicking on “References” and then select “Browse…”. Find and add the DLLs to the class library project.

Reference the class library in the web project by right clicking on “References”, select “Projects” and then “Solution”.

The Packages of the web project are restored and the project.json is modified automatically.

  "frameworks": {
    "dnx451": {
      "dependencies": {
        "ClassLib1": "1.0.0-*"
      }
   }

Upvotes: 0

Fabjan
Fabjan

Reputation: 13676

Not sure how are you going to add reference to assembly dynamically if you haven't loaded it yet. But you can just load your assembly from a file with :

Assembly.LoadFrom("MyAssembly.dll");

Upvotes: 0

Related Questions