目前在开发标题中的组件,在组件中需要调用第三方C++版本的DLL库,该库用于视频设备的操控,并且该组件运行在JSP页面中,DLL库中需要相关的Struct的封装,下面将列出:
[StructLayoutAttribute(LayoutKind.Explicit)]
public struct WIFI_AUTH_PARAM
{
[FieldOffsetAttribute(0)]
public UNION_EAP_TTLS EAP_TTLS;
[FieldOffsetAttribute(0)]
public UNION_EAP_PEAP EAP_PEAP;
[FieldOffsetAttribute(0)]
public UNION_EAP_TLS EAP_TLS;
}
结构体中第一个Struct我将进行说明:
[StructLayoutAttribute(LayoutKind.Sequential, CharSet = CharSet.Ansi, Size = 144)]
public struct UNION_EAP_TTLS
{
public byte byEapolVersion;
public byte byAuthType;
[MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = 2, ArraySubType = UnmanagedType.I1)]
public byte[] byRes1;
[MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = NAME_LEN, ArraySubType = UnmanagedType.I1)]
public byte[] byAnonyIdentity;
[MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = NAME_LEN, ArraySubType = UnmanagedType.I1)]
public byte[] byUserName;
[MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = NAME_LEN, ArraySubType = UnmanagedType.I1)]
public byte[] byPassword;
[MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = 44, ArraySubType = UnmanagedType.I1)]
public byte[] byRes;
}
但是在运行时遇到错误:Error 13 Cannot register assembly "D:\Code\NET\Casic.ActiveX\Casic.ActiveX\bin\Debug\Casic.ActiveX.dll". Could not load type 'WIFI_AUTH_PARAM' from assembly 'Casic.ActiveX, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' because it contains an object field at offset 0 that is incorrectly aligned or overlapped by a non-object field.
如果去掉项目-》属性 -》Build (Register for COM interop)选项,则编译顺利通过,请各位帮帮忙,谢谢大家!
关注!
楼主解决了没?
使用管理员身份运行IDE