I've got an IIS v6 (Windows Server 2003) web site which uses some old DLL written with unmanaged code. (Aspx, C# using System.Runtime.InteropService to call unmanaged dll)
But I've bought a new Windows Server 2008 with IIS7 and call to unmanaged DLL is not working.
In fact my C# code call an unmanaged DLL but the code never ends. It's entering in DLL code (all is working until the <return> instruction, but it does not return to C# !!).
I've tried to configure the application pool (classic mode), the web site properties... but to hard for me.At a time I got the error "IIS Worker Thread stop working"!
A sample:
ASPX
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Table runat="server">
<asp:TableRow>
<asp:TableCell>
<asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
</asp:TableCell>
</asp:TableRow>
</asp:Table>
</div>
</form>
</body>
</html>
CS
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Runtime.InteropServices;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
[DllImport("user32.dll")]
static extern int MessageBoxA(int hWnd, string title, string msg, int type);
protected void Button1_Click(object sender, EventArgs e)
{
MessageBoxA(0, "Hello world !!", "Hello world !!", 0);
}
}
With IIS6, when the button is clicked a message box is displayed. With IIS7 nothing is displayed !
Any idea ?
Thanks for help !