Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. IIS 6 to IIS 7 not working with unmanaged code

IIS 6 to IIS 7 not working with unmanaged code

Scheduled Pinned Locked Moved ASP.NET
windows-admincsharpc++htmldesign
2 Posts 2 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Le Sourcier
    wrote on last edited by
    #1

    I've got an IIS v6 (Windows Server 2003) web site which uses an 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 the 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" %>

    <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:TableRow
    asp:TableCell
    <asp:Literal ID="Literal1" runat="server"></asp:Literal>
    </asp:TableCell>
    </asp:TableRow>
    </asp:Table>
    </div>
    </form>
    </body>
    </html>

    CS

    using System;
    using System.Runtime.InteropServices;

    public partial class _Default : System.Web.UI.Page
    {
    [DllImport("MyDLL.dll", EntryPoint = "?get_html@@YAPBDN@Z")]
    static extern string get_html(double value);

    protected void Button1\_Click(object sender, EventArgs e)
    {
        Random a = new Random();
        Literal1.Text = get\_html(a.NextDouble());
    }
    

    }

    DLL C++

    #include "stdafx.h"
    #include "stdio.h"

    char myBuffer[MAX_PATH];

    __declspec(dllexport) const char * get_html(double value)
    {
    memset(myBuffer, 0x00, MAX_PATH);
    sprintf(myBuffer, "<html><title>Test</title></head><body>Entered value : %.2f<br>Value x2 = %.2f</body></html>", value, value*2);
    return myBuffer;
    }

    With IIS6, when the button is clicked the HTML text is displayed (all is good). With IIS7 nothing is happening !

    U 1 Reply Last reply
    0
    • L Le Sourcier

      I've got an IIS v6 (Windows Server 2003) web site which uses an 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 the 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" %>

      <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:TableRow
      asp:TableCell
      <asp:Literal ID="Literal1" runat="server"></asp:Literal>
      </asp:TableCell>
      </asp:TableRow>
      </asp:Table>
      </div>
      </form>
      </body>
      </html>

      CS

      using System;
      using System.Runtime.InteropServices;

      public partial class _Default : System.Web.UI.Page
      {
      [DllImport("MyDLL.dll", EntryPoint = "?get_html@@YAPBDN@Z")]
      static extern string get_html(double value);

      protected void Button1\_Click(object sender, EventArgs e)
      {
          Random a = new Random();
          Literal1.Text = get\_html(a.NextDouble());
      }
      

      }

      DLL C++

      #include "stdafx.h"
      #include "stdio.h"

      char myBuffer[MAX_PATH];

      __declspec(dllexport) const char * get_html(double value)
      {
      memset(myBuffer, 0x00, MAX_PATH);
      sprintf(myBuffer, "<html><title>Test</title></head><body>Entered value : %.2f<br>Value x2 = %.2f</body></html>", value, value*2);
      return myBuffer;
      }

      With IIS6, when the button is clicked the HTML text is displayed (all is good). With IIS7 nothing is happening !

      U Offline
      U Offline
      User 12987475
      wrote on last edited by
      #2

      Did you get this issue resolved? I'm having a similar issue and haven't found anything online yet to resolve it.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups