当前位置:网站首页>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
边栏推荐
- js实现文字跑马灯效果
- Is Guoxin golden sun reliable? Is it safe to open a securities account?
- Add an "open search description" to the site to adapt to the browser's "site search"“
- usb peripheral 驱动 - 枚举
- Gradient
- 路由跳转之点击列表的操作按钮,跳转至另一个菜单页面并激活相应的菜单
- Popupwindow utility class
- Upload file / text / picture, box shadow
- String到底能不能改变?
- 云计算基础-0
猜你喜欢

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

MySQL addition, deletion, query and modification (primary level)

Run multiple main functions in the clion project

Uni app custom drop-down selection list

Nepal graph learning Chapter 3_ Multithreading completes 6000w+ relational data migration

Classic model - Nin & googlenet

MySQL advanced part (IV: locking mechanism and SQL optimization)

栖霞消防开展在建工地消防安全培训

String到底能不能改变?

进度条
随机推荐
Run multiple main functions in the clion project
Cliquez sur le bouton action de la liste pour passer à une autre page de menu et activer le menu correspondant
mysql存储过程
360 second understanding of smartx hyper converged infrastructure
Uni app custom navigation bar component
Can string be changed?
WebRTC系列-网络传输之6-Connections裁剪
ASP. Net startup and running mechanism
Android gap animation translate, scale, alpha, rotate
Class diagram
An easy-to-use tablayout
mysql存儲過程
请求对象,发送请求
多媒体元素,音频、视频
USB driver -debug
String到底能不能改变?
After Ali failed to start his job in the interview, he was roast by the interviewer in the circle of friends (plug)
2022.6.24-----leetcode.515
The kotlin project is running normally and the R file cannot be found
Upload file / text / picture, box shadow