I have an MVC application that loads an external DLL, and when I'm in production, I don't get any errors at all. Firefox just says the connection was reset. So I put some try / catch in the code, but they still do not work, I still get a reset message.
I know the error is a BadImageFormatException exception, but why can't I see anything in the browser?
public class HomeController : Controller
{
[DllImport("CDCrypt.dll")]
[return: MarshalAs(UnmanagedType.LPStr)]
public static extern String Encrypt([MarshalAs(UnmanagedType.LPStr)] String aName);
[DllImport("CDCrypt.dll")]
[return: MarshalAs(UnmanagedType.LPStr)]
public static extern String Decrypt([MarshalAs(UnmanagedType.LPStr)] String aName);
public ActionResult Index()
{
try
{
ViewBag.EncryptString = Encrypt("test");
}
catch (Exception e)
{
ViewBag.EncryptString = "Stack Trace\r\n:" + "\r\nException: " + e.Message;
return new HttpStatusCodeResult(500);
}
return View();
}
public ActionResult Up()
{
ViewBag.Up = "You can see me";
return View();
}
}
source
share