当前位置:网站首页>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
边栏推荐
- Nebula Graph学习篇3_多线程完成6000w+关系数据迁移
- XGBoost, lightGBM, CatBoost——尝试站在巨人的肩膀上
- 2022.6.25 - leetcode. Un doigt d'épée. 091.
- 拖放
- Qixia fire department carries out fire safety training on construction site
- [paper notes] supersizing self supervision: learning to grasp from 50K tries and 700 robot hours
- Insect structure and Deconstruction
- Solve the problem that the uniapp plug-in Robin editor reports an error when setting the font color and background color
- Types and application methods of screen printing
- Is the compass app regular? Is it safe or not
猜你喜欢

优化——多目标规划

When the tiflash function is pushed down, it must be known that it will become a tiflash contributor in ten minutes

Kotlin quick start

Uni app custom selection date 2 (September 16, 2021)

Multimedia elements, audio, video

Tupu software is the digital twin of offshore wind power, striving to be the first

解决uniapp插件robin-editor设置字体颜色和背景颜色报错的问题

多媒体元素,音频、视频

Uni app custom selection date 1 (September 16, 2021)

Camera-memory内存泄漏分析(二)
随机推荐
Uni app custom navigation bar component
169. 多数元素
国信金太阳靠谱吗?开证券账户安全吗?
Redux thunk simple case, advantages, disadvantages and thinking
Kotlin quick start
An easy-to-use tablayout
阿里云函数计算服务一键搭建Z-Blog个人博客
mysql 常用语句
【哈希表】很简单的拉链法哈希结构,以至于效果太差,冲突太多,链表太长
进度条
Classic model alexnet
Uni app custom selection date 2 (September 16, 2021)
2022.6.25-----leetcode. Sword finger offer 091
MySQL高级部分( 四: 锁机制、SQL优化 )
Uni app QR code scanning and identification function
MySQL高级篇第一章(linux下安装MySQL)【下】
Evaluation - analytic hierarchy process
Nebula Graph学习篇3_多线程完成6000w+关系数据迁移
点击事件
“再谈”协议