//类定义
public class Classxxoo
{
private const int MAX_CLIPENUM_IN_BLOCK = 254;
private const int BLOCK_INDEX_NUM = (8 * 1024);
//[StructLayout(LayoutKind.Sequential)]
private struct Block_File
{
public uint frameNum;
public uint clipStime;
public uint clipEtime;
public uint clip_size;
public uint index_num;
} //[StructLayout(LayoutKind.Sequential)]
private struct clipIdx_info_t
{
public byte channel;
public byte status;
public ushort fileInfoIdx;
public Block_File blkfile; //注意,这一行注释掉就正常工作了
public uint index_off;
public uint clip_off;
} //[StructLayout(LayoutKind.Sequential)]
private struct KeyIndex
{
public uint cKeyOffset;
public uint TimeStampSec;
} //[StructLayout(LayoutKind.Sequential)]
private struct blockIdx_info_t
{
public uint block_inf;
public uint block_size;
public uint block_no;
public byte channel;
public byte block_status;
public byte block_type;
public byte clip_num;
public uint recover_num;
public uint write_Size;
public uint blockStime;
public uint blockEtime;
public uint index_num;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 28)]
public byte[] rev;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
public clipIdx_info_t[] clip_info;
} private blockIdx_info_t m_FileIndex; public Classxxoo( )
{
m_FileIndex = new blockIdx_info_t();
}
}
//------------------运行代码------------------------ class Program
{
static void Main(string[] args)
{
Classxxoo xxoo = new Classxxoo( );
Console.WriteLine(xxoo.ToString());
Console.Read();
}
}异常提示
未处理 System.TypeLoadException
Message=未能从程序集“ConsoleApplication1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null”中加载类型“ConsoleApplication1.Classxxoo”。
Source=ConsoleApplication1
TypeName=ConsoleApplication1.Classxxoo
StackTrace:
在 ConsoleApplication1.Program.Main(String[] args)
在 System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
在 System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
在 Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
在 System.Threading.ThreadHelper.ThreadStart_Context(Object state)
在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
在 System.Threading.ThreadHelper.ThreadStart()
InnerException:
解决方案 »
- 高分求解WIN7+VS2010+VSTO编译失败
- 【求助】帮我看看这个网站如何实现自动登录
- 自定义的控件如何通过bindingSource数据源的绑定某一属性
- 关于SendMessage向listview发送消息,改变图标排列方式的问题。
- ICSharpCode.TextEditor的几个问题。
- C# 利用客户端证书访问webservice
- 在C#中调用MSCOMM32.OCX的问题
- winform界面的问题,请有经验的大哥大姐们帮忙一下了
- 用Dns.GetHostEntry(hostName)获取的IP地址不能用!请帮忙!谢谢!
- 读数据库表问题。
- 弱弱的问下 winform 的 dataGridView 如何绑定mysql?
- 求高手能解这道题的!给分40分!
在C#里这样定义就会挂掉
{ public class Classxxoo
{ [StructLayout(LayoutKind.Explicit , Size = 4)]
private struct Block_File
{
[FieldOffset(0)]
public int frameNum;
} [StructLayout(LayoutKind.Explicit , Size = 8)]
private struct clipIdx_info_t
{
[FieldOffset(0)]
public int clip_off;
[FieldOffset(4),MarshalAs(UnmanagedType.ByValArray,SizeConst=1 )]
public Block_File blkfile;
}
[StructLayout(LayoutKind.Explicit , Size = 16)]
private struct blockIdx_info_t
{
[FieldOffset(0) , MarshalAs(UnmanagedType.ByValArray , SizeConst = 8)]
public clipIdx_info_t[] clip_info;
}
private blockIdx_info_t m_FileIndex;
public Classxxoo( )
{
m_FileIndex = new blockIdx_info_t();
}
}[/code]
//结构体定义
//[StructLayout(LayoutKind.Sequential)]
struct Block_File
{
public uint frameNum;
public uint clipStime;
public uint clipEtime;
public uint clip_size;
public uint index_num;
} //[StructLayout(LayoutKind.Sequential)]
struct clipIdx_info_t
{
public byte channel;
public byte status;
public ushort fileInfoIdx;
public Block_File blkfile; //注意,这一行注释掉就正常工作了
public uint index_off;
public uint clip_off;
} //[StructLayout(LayoutKind.Sequential)]
struct KeyIndex
{
public uint cKeyOffset;
public uint TimeStampSec;
} //[StructLayout(LayoutKind.Sequential)]
struct blockIdx_info_t
{
public uint block_inf;
public uint block_size;
public uint block_no;
public byte channel;
public byte block_status;
public byte block_type;
public byte clip_num;
public uint recover_num;
public uint write_Size;
public uint blockStime;
public uint blockEtime;
public uint index_num;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 28)]
public byte[] rev;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
public clipIdx_info_t[] clip_info;
}
//类定义
public class Classxxoo
{
private const int MAX_CLIPENUM_IN_BLOCK = 254;
private const int BLOCK_INDEX_NUM = (8 * 1024);
private blockIdx_info_t m_FileIndex; public Classxxoo( )
{
m_FileIndex = new blockIdx_info_t();
}
}
//------------------运行代码------------------------ class Program
{
static void Main(string[] args)
{
Classxxoo xxoo = new Classxxoo( );
Console.WriteLine(xxoo.ToString());
Console.Read();
}
}