473,387 Members | 1,892 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

TypeLoad Exception

Hi,

I'm getting an System.TypeLoadException with this type def:

[StructLayout(LayoutKind.Explicit, CharSet=CharSet.Ansi)]
public struct SCFEDBTxnItem
{
[FieldOffset(0)] public SCFEDBTxnItemHeader sHeader;
[FieldOffset(0)] public SCFEDBTxnOrderItem sOrder;
[FieldOffset(0)] public SCFEDBTxnTradeItem sTrade;
[FieldOffset(0)] public SCFEDBTxnErrorItem sError;
[FieldOffset(0)] public SCFEDBTxnRequestItem sRequest;
}

So, what is the problem?
Nov 16 '05 #1
4 5522
Tunga,

What is the exception you are getting? It is most likely that the type
load exception is not coming from the code, but some other factor. Can you
give the full details of the exception?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Tunga Torgal" <tu*********@hotmail.com> wrote in message
news:%2******************@tk2msftngp13.phx.gbl...
Hi,

I'm getting an System.TypeLoadException with this type def:

[StructLayout(LayoutKind.Explicit, CharSet=CharSet.Ansi)]
public struct SCFEDBTxnItem
{
[FieldOffset(0)] public SCFEDBTxnItemHeader sHeader;
[FieldOffset(0)] public SCFEDBTxnOrderItem sOrder;
[FieldOffset(0)] public SCFEDBTxnTradeItem sTrade;
[FieldOffset(0)] public SCFEDBTxnErrorItem sError;
[FieldOffset(0)] public SCFEDBTxnRequestItem sRequest;
}

So, what is the problem?

Nov 16 '05 #2
First, this is union...
So, everyfield must start at the same offset...

Am I wrong? Maybe, I did not understand the concept of fieldoffsets and
layoutkind.explicit...

"Dilip Krishnan" <dilipdotnet..NOSPAM..@apdiya.com> wrote in message
news:eU**************@TK2MSFTNGP10.phx.gbl...
Tunga,
From what I see its not byte aligned. Every feild seems to be at
offset 0. If for example sHeader is 4 bytes long then FieldOffset for
the sOrder field should be FieldOffset(4)
Hope that helps

Tunga Torgal wrote:
Hi,

I'm getting an System.TypeLoadException with this type def:

[StructLayout(LayoutKind.Explicit, CharSet=CharSet.Ansi)]
public struct SCFEDBTxnItem
{
[FieldOffset(0)] public SCFEDBTxnItemHeader sHeader;
[FieldOffset(0)] public SCFEDBTxnOrderItem sOrder;
[FieldOffset(0)] public SCFEDBTxnTradeItem sTrade;
[FieldOffset(0)] public SCFEDBTxnErrorItem sError;
[FieldOffset(0)] public SCFEDBTxnRequestItem sRequest;
}

So, what is the problem?


--
Regards,
Dilip Krishnan
MCAD, MCSD.net
dilipdotnet at apdiya dot com

Nov 16 '05 #3
Tunga,
From what I see its not byte aligned. Every feild seems to be at
offset 0. If for example sHeader is 4 bytes long then FieldOffset for
the sOrder field should be FieldOffset(4)
Hope that helps

Tunga Torgal wrote:
Hi,

I'm getting an System.TypeLoadException with this type def:

[StructLayout(LayoutKind.Explicit, CharSet=CharSet.Ansi)]
public struct SCFEDBTxnItem
{
[FieldOffset(0)] public SCFEDBTxnItemHeader sHeader;
[FieldOffset(0)] public SCFEDBTxnOrderItem sOrder;
[FieldOffset(0)] public SCFEDBTxnTradeItem sTrade;
[FieldOffset(0)] public SCFEDBTxnErrorItem sError;
[FieldOffset(0)] public SCFEDBTxnRequestItem sRequest;
}

So, what is the problem?


--
Regards,
Dilip Krishnan
MCAD, MCSD.net
dilipdotnet at apdiya dot com
Nov 16 '05 #4
Aah unions! I'm guessing, but I think its possibly because they field
offsets dont work for reference types? Basically it cant compute the
union type because it cant compute the sizes at design time?

Tunga Torgal wrote:
First, this is union...
So, everyfield must start at the same offset...

Am I wrong? Maybe, I did not understand the concept of fieldoffsets and
layoutkind.explicit...

"Dilip Krishnan" <dilipdotnet..NOSPAM..@apdiya.com> wrote in message
news:eU**************@TK2MSFTNGP10.phx.gbl...
Tunga,
From what I see its not byte aligned. Every feild seems to be at
offset 0. If for example sHeader is 4 bytes long then FieldOffset for
the sOrder field should be FieldOffset(4)
Hope that helps

Tunga Torgal wrote:

Hi,

I'm getting an System.TypeLoadException with this type def:

[StructLayout(LayoutKind.Explicit, CharSet=CharSet.Ansi)]
public struct SCFEDBTxnItem
{
[FieldOffset(0)] public SCFEDBTxnItemHeader sHeader;
[FieldOffset(0)] public SCFEDBTxnOrderItem sOrder;
[FieldOffset(0)] public SCFEDBTxnTradeItem sTrade;
[FieldOffset(0)] public SCFEDBTxnErrorItem sError;
[FieldOffset(0)] public SCFEDBTxnRequestItem sRequest;
}

So, what is the problem?


--
Regards,
Dilip Krishnan
MCAD, MCSD.net
dilipdotnet at apdiya dot com



--
Regards,
Dilip Krishnan
MCAD, MCSD.net
dilipdotnet at apdiya dot com
Nov 16 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Nicolas Fleury | last post by:
Hi, I've made a small utility to re-raise an exception with the same stack as before with additional information in it. Since I want to keep the same exception type and that some types have very...
0
by: gabe | last post by:
Hello, I've been getting a TypeLoadException after doing a VBC command line build. I've included all of the /r - references and /i - imports for the assembly. The exception is thrown at runtime...
1
by: Old Wolf | last post by:
1. What is the difference between #include <stdexcept> and #include <exception> ? 2. Is there a list somewhere of what each standard exception is used for? either to throw them, or throw...
11
by: Master of C++ | last post by:
Hi, I am writing a simulation package in C++, and so far I've written about 8000 lines of code and have about 30 classes. I haven't used C++ exceptions so far (for various reasons). The only two...
4
by: maricel | last post by:
I have the following base table structure - DDL: CREATE TABLE "ADMINISTRATOR"."T1" ( "C1" INTEGER NOT NULL ) IN "TEST_TS" ; ALTER TABLE "ADMINISTRATOR"."T1" ADD PRIMARY KEY
5
by: PCC | last post by:
I am using the Exception Managment Application Block on Windows Server 2003 Enterprise and .NET v1.1. If I use the block with an ASP.NET web wervice or in a web application I get the following...
0
by: Tunga Torgal | last post by:
I get a typeload exception saying "because it contains an object field at offset 0 that is incorrectly aligned or overlapped by a non-object field." " here is my types :
44
by: craig | last post by:
I am wondering if there are some best practices for determining a strategy for using try/catch blocks within an application. My current thoughts are: 1. The code the initiates any high-level...
3
by: JohnDeHope3 | last post by:
First let me say that I understand that Asp.Net wraps my exception in an HttpUnhandledException. I have found a lot of discussion about that on the web, which was informative, but not helpful. Let...
2
by: Darko Miletic | last post by:
Recently I wrote a dll in c++ and to simplify the distribution I decided to link with multithreaded static library (/MT or /MTd option). In debug everything works fine but in release I get this: ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.