当前位置:网站首页>Contains an object field at offset position
Contains an object field at offset position
2022-06-26 03:44:00 【yuyue5945】
TypeLoadException: Failed to remove from assembly “ECS.GUI.Define, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null” Load type in “ECS.GUI.Define.ArmgAimPos”, Because it is in 4 The offset contains an object field , The field has been improperly aligned or overlapped by a non object field
The keyword of the exception is : stay 4 The offset contains an object field
By finding objects , The object is the Commons
// StructLayout Enables the designer to control the physical layout of the data fields of a class or structure
// Explicit And FieldOffset Together, you can control the exact location of each data member
[StructLayout(LayoutKind.Explicit)]
public struct ArmgAimPos
{
[FieldOffset(0)] public BayType type;
[FieldOffset(4)] public string ContainerID;
[FieldOffset(8)] public string JobID;
Use FieldOffset Property implements Commons and casts
Initialize with the offset in the structure where the field starts FieldOffsetAttribute class .
c#
public FieldOffsetAttribute (int offset);
Parameters
offset Int32
The offset from the beginning of the structure to the beginning of the field ( In bytes ).
The concept that can be expressed is : The principle is actually the same C++ equally , Will a int[] The variable of type is related to byte[] The same memory area as type variable , Follow C++ Lieutenant general dat Point to char The first address of the array is the same . Again , The function of such a structure is related to C++ The Commons of are the same , That is, a structure can be used as multiple data types , And the specific type depends on the situation .
Modify exception methods :
As the prompt title shows :4 Offset position , There is already a non object field , therefore , Move the offset backward to solve
// StructLayout Enables the designer to control the physical layout of the data fields of a class or structure
// Explicit And FieldOffset Together, you can control the exact location of each data member
[StructLayout(LayoutKind.Explicit)]
public struct ArmgAimPos
{
[FieldOffset(0)] public BayType type;
[FieldOffset(8)] public string ContainerID;
[FieldOffset(16)] public string JobID;
[ FieldOffset( 8)] public string ContainerID;
The offset is changed to 8 , Problem fix
边栏推荐
猜你喜欢

计组笔记——CPU的指令流水

Solve the problem that the uniapp plug-in Robin editor reports an error when setting the font color and background color

You cannot call Glide. get() in registerComponents(), use the provided Glide instance instead

Kotlin uses viewpager2+fragment+bottomnavigationview to implement the style of the switching module of the bottom menu bar.

The "eye" of industrial robot -- machine vision

ASP. Net startup and running mechanism

Class diagram

分割、柱子、list

Double carbon bonus + great year of infrastructure construction 𞓜 deep ploughing into the field of green intelligent equipment for water conservancy and hydropower

Qt 中 deleteLater 使用总结
随机推荐
Some mobile phones open USB debugging, and the solution to installation failure
Navicat16 wireless trial
Sqlitestudio download address
Uni app custom selection date 1 (September 16, 2021)
【哈希表】改进,拉链法哈希结构——直接用两个索引查找,不用每次都hash和%一遍
等保备案是等保测评吗?两者是什么关系?
Asynctask multiple simultaneous use methods
Upload file / text / picture, box shadow
HL7Exception: Can‘t XML-encode a GenericMessage. Message must have a recognized struct
mysql 常用语句
MySQL高级篇第一章(linux下安装MySQL)【下】
[paper notes] supersizing self supervision: learning to grasp from 50K tries and 700 robot hours
进程之间的通信方式
js实现文字跑马灯效果
Classic model - Nin & googlenet
Pay attention to the entrance components of official account in the applet
Do you want to add a key to the applet or for sequence?
View of MySQL
路由跳转之点击列表的操作按钮,跳转至另一个菜单页面并激活相应的菜单
Kotlin uses viewpager2+fragment+bottomnavigationview to implement the style of the switching module of the bottom menu bar.