I have a DLL that I have developed. I use this DLL in a website using DllImport
.
When I run the website via Visual Studio all is okay, but when I run it with the IIS it is stuck with no errors.
Here's my code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using System.Runtime.InteropServices;
using System.Web.Script.Serialization;
using System.Text.RegularExpressions;
namespace WebApplication1
{
public partial class WebForm1 : System.Web.UI.Page
{
[DllImport("D:\\WebApplication1\\WebApplication1\\bin\\dapreporter.dll", CallingConvention = CallingConvention.StdCall)]
public static extern IntPtr fndapreporter(string inifile, int nReport, int nYear, int nMonth, int nDay, int nType, int nCode, int precision);
protected void Page_Load(object sender, EventArgs e)
{
try
{
string iniFile = File.ReadAllText(@"D:\WebApplication1\WebApplication1\bin\WinDAP.ini");
IntPtr pVariant = fndapreporter(iniFile, 0, 2021, 9, 12, 0, 197, 0);
object sHtml = Marshal.GetObjectForNativeVariant(pVariant);
Marshal.FreeCoTaskMem(pVariant);
pVariant = IntPtr.Zero;
Response.Write(sHtml.ToString());
}
catch(Exception ex)
{
Response.Write("ERROR: " + ex.Message);
}
}
}
}