Dev Ngron
Dev Ngron

Reputation: 135

Reference a dll inside a folder within the bin folder

Inside my Bin folder I created another folder called "Template" (Bin > Template). Inside the Template folder I have a set of dll's, of which I would like to call from a class; like... using Bin.Template.Example.ClassName; Is it possible to accomplish this?

Upvotes: 0

Views: 4320

Answers (2)

Chris Pickford
Chris Pickford

Reputation: 8991

To use an external DLL from the filesystem, you need to add a reference at the project level. Right click References under your project, and choose Add Reference...:

enter image description here

Then click Browse button, locate the DLL, press Ok.

Inside your class file, add using <dll.name.space>; to the top.

Upvotes: 0

Ross Miller
Ross Miller

Reputation: 646

Yes you can use Assembly.LoadFile to load external assemblies.

        var x = Assembly.LoadFile("myFile.dll");
        var myObject = x.CreateInstance("MyClass");

However you will not have strongly typed access to the resulting object.

Consider using dependency injection instead, where you will be able to load assemblies and know the types.

Upvotes: 1

Related Questions