我有一个MVC应用程序,它加载了一个外部的DLL文件。在生产环境中,我根本没有收到任何错误信息。火狐浏览器只是显示连接被重置。所以我在代码中加入了一些try/catch语句,但它们仍然不起作用,我仍然会收到连接重置的消息。
我知道这个错误是BadImageFormatException,但为什么我在浏览器中看不到任何东西呢?
我知道这个错误是BadImageFormatException,但为什么我在浏览器中看不到任何东西呢?
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);
//
// GET: /Home/
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();
}
}