ITWorker ITWorker - 2 months ago 15
ASP.NET (C#) Question

How to access DLL in bin folder of ASP.NET MVC project?

I am trying to use the following to access a DLL in the project's bin folder:

[HttpPost]
public ActionResult EncryptFile()
{
Assembly SampleAssembly;


var dllFile = new FileInfo(@".\\bin\\encrypt.dll");
SampleAssembly = Assembly.LoadFile(dllFile.FullName);
//...trimmed...
}


I also attempted
var dllFile = new FileInfo(@"\\bin\\encrypt.dll");
(note lack of
.
before the filepath), but it did not work either. In the debugger, the
FullName
returns
\\\\bin\\encrypt.dll
in this second case.

What can I do to make it locate the file?

Thank you.

Answer

Do

Assembly SampleAssembly = Assembly.LoadFile(Server.MapPath(@"~/bin/encrypt.dll"));