【发布时间】:2016-05-07 10:43:28
【问题描述】:
在发布 Azure Web 应用程序后,尝试从 C# 对 gdi32.dll 函数进行一些基本调用,但遇到了很多问题。是完全支持还是我可以进行解决方法/配置更改?
在标准设置下在 Visual Studio 中运行时,下面的指针都返回非零值,但在 Azure 中运行时它们返回 0。
创建了一个基本的 ASP.NET Web Forms 项目,并在Default.aspx 的代码隐藏中添加了打击以进行测试:
[DllImport("gdi32.dll")]
private static extern IntPtr CreatePen(int enPenStyle, int nWidth, uint crColor);
[DllImport("gdi32.dll")]
private static extern IntPtr SelectObject(IntPtr hdc, IntPtr hgdiobj);
[DllImport("gdi32.dll")]
private static extern bool MoveToEx(IntPtr hdc, int X, int Y, IntPtr lpPoint);
[DllImport("gdi32.dll")]
private static extern bool LineTo(IntPtr hdc, int nXEnd, int nYEnd);
[DllImport("gdi32.dll")]
private static extern bool DeleteObject([In] IntPtr hObject);
protected void Page_Load(object sender, EventArgs e)
{
using (Bitmap bitmap = new Bitmap(100, 100))
{
using (Graphics graphics = Graphics.FromImage(bitmap))
{
IntPtr hdc = graphics.GetHdc();
IntPtr pen = CreatePen(0, (int)2, (uint)0);
IntPtr hObject = SelectObject(hdc, pen);
DeleteObject(hObject);
DeleteObject(pen);
graphics.ReleaseHdc();
Response.Write(string.Format("HDC handle: {0}", hdc));
Response.Write("<br/>");
Response.Write(string.Format("CreatePen pen: {0}", hObject));
Response.Write("<br/>");
Response.Write(string.Format("SelectObject returned: {0}", hObject));
}
}
}
【问题讨论】:
标签: c# .net azure azure-web-app-service gdi