小编use*_*994的帖子

如何编组指向结构数组指针的指针?

我的C声明如下:

int myData(uint myHandle, tchar *dataName, long *Time, uint *maxData, DATASTRUCT **data);

typedef struct {
  byte Rel;
  __int64 Time;
  char Validated;
  unsigned char Data[1];
} DATASTRUCT ;
Run Code Online (Sandbox Code Playgroud)

我的C#声明如下:

[DllImport("myData.dll", EntryPoint = "myData")]
public static extern int myData(uint myHandle, [MarshalAs(UnmanagedType.LPTStr)] string dataName, out long Time, out uint maxData, ref DATASTRUCT[] data);

[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct DATASTRUCT
{
    public sbyte Rel;
    public long Time;
    public byte Validated;
    public double Data;
}
Run Code Online (Sandbox Code Playgroud)

然后我调用托管函数如下:

string dataToShow = "description";
long Time;
uint maxData; …
Run Code Online (Sandbox Code Playgroud)

.net c# pinvoke interop marshalling

8
推荐指数
1
解决办法
1万
查看次数

自定义错误一旦部署在 IIS 上就不能在本地工作

我有以下几点:

Web.config

<system.web>
<authentication mode="None" />
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
<customErrors mode="On" defaultRedirect="~/Error/ShowError">
  <error redirect="~/Error/ShowError/400" statusCode="400" />
  <error redirect="~/Error/ShowError/401" statusCode="401" />
  <error redirect="~/Error/ShowError/403" statusCode="403" />
  <error redirect="~/Error/ShowError/404" statusCode="404" />
</customErrors>
</system.web>
Run Code Online (Sandbox Code Playgroud)

ErrorController

[AllowAnonymous]
public class ErrorController : Controller
{
    public ViewResult ShowError(int id)
    {
        Response.StatusCode = id;
        switch (id)
        {
            case 400:
                return View("~/Views/Error/400.cshtml");
            case 401:
                return View("~/Views/Error/401.cshtml");
            case 403:
                return View("~/Views/Error/403.cshtml");
            case 404:
                return View("~/Views/Error/404.cshtml");
            default:
                return View("~/Views/Error/404.cshtml");
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

FilterConfig

    public static void RegisterGlobalFilters(GlobalFilterCollection …
Run Code Online (Sandbox Code Playgroud)

c# asp.net asp.net-mvc web-config http-status-codes

3
推荐指数
1
解决办法
842
查看次数