Jon*_*Jon 3 .net c# asp.net-mvc dllimport asp.net-mvc-3
我有一个加载外部DLL的MVC应用程序,在生产中我根本没有错误.Firefox只是说连接已重置.所以我在代码中放了一些try/catch但它们仍然无法工作,我仍然得到连接重置消息.
我知道错误是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();
}
}
Run Code Online (Sandbox Code Playgroud)