473,545 Members | 1,650 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

TypeLoad Exception

Hi,

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

[StructLayout(La youtKind.Explic it, CharSet=CharSet .Ansi)]
public struct SCFEDBTxnItem
{
[FieldOffset(0)] public SCFEDBTxnItemHe ader sHeader;
[FieldOffset(0)] public SCFEDBTxnOrderI tem sOrder;
[FieldOffset(0)] public SCFEDBTxnTradeI tem sTrade;
[FieldOffset(0)] public SCFEDBTxnErrorI tem sError;
[FieldOffset(0)] public SCFEDBTxnReques tItem sRequest;
}

So, what is the problem?
Nov 16 '05 #1
4 5547
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.co m

"Tunga Torgal" <tu*********@ho tmail.com> wrote in message
news:%2******** **********@tk2m sftngp13.phx.gb l...
Hi,

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

[StructLayout(La youtKind.Explic it, CharSet=CharSet .Ansi)]
public struct SCFEDBTxnItem
{
[FieldOffset(0)] public SCFEDBTxnItemHe ader sHeader;
[FieldOffset(0)] public SCFEDBTxnOrderI tem sOrder;
[FieldOffset(0)] public SCFEDBTxnTradeI tem sTrade;
[FieldOffset(0)] public SCFEDBTxnErrorI tem sError;
[FieldOffset(0)] public SCFEDBTxnReques tItem 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.expl icit...

"Dilip Krishnan" <dilipdotnet..N OSPAM..@apdiya. com> wrote in message
news:eU******** ******@TK2MSFTN GP10.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.TypeLoad Exception with this type def:

[StructLayout(La youtKind.Explic it, CharSet=CharSet .Ansi)]
public struct SCFEDBTxnItem
{
[FieldOffset(0)] public SCFEDBTxnItemHe ader sHeader;
[FieldOffset(0)] public SCFEDBTxnOrderI tem sOrder;
[FieldOffset(0)] public SCFEDBTxnTradeI tem sTrade;
[FieldOffset(0)] public SCFEDBTxnErrorI tem sError;
[FieldOffset(0)] public SCFEDBTxnReques tItem 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.TypeLoad Exception with this type def:

[StructLayout(La youtKind.Explic it, CharSet=CharSet .Ansi)]
public struct SCFEDBTxnItem
{
[FieldOffset(0)] public SCFEDBTxnItemHe ader sHeader;
[FieldOffset(0)] public SCFEDBTxnOrderI tem sOrder;
[FieldOffset(0)] public SCFEDBTxnTradeI tem sTrade;
[FieldOffset(0)] public SCFEDBTxnErrorI tem sError;
[FieldOffset(0)] public SCFEDBTxnReques tItem 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.expl icit...

"Dilip Krishnan" <dilipdotnet..N OSPAM..@apdiya. com> wrote in message
news:eU******** ******@TK2MSFTN GP10.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.TypeLoad Exception with this type def:

[StructLayout(La youtKind.Explic it, CharSet=CharSet .Ansi)]
public struct SCFEDBTxnItem
{
[FieldOffset(0)] public SCFEDBTxnItemHe ader sHeader;
[FieldOffset(0)] public SCFEDBTxnOrderI tem sOrder;
[FieldOffset(0)] public SCFEDBTxnTradeI tem sTrade;
[FieldOffset(0)] public SCFEDBTxnErrorI tem sError;
[FieldOffset(0)] public SCFEDBTxnReques tItem 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
2749
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 specific constructors (which take, for example, more than one parameter), the only safe way I have found to made it is by hacking the str...
0
837
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 from and ASP.Net application when accessing a business object. The Business Object is inherited from a custom base class references in a different...
1
4200
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 user-defined exceptions derived from them? (for example I have been deriving mine from std::bad_alloc if there was a memory problem, or std::bad_exception...
11
3255
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 "resources" I use are memory and file I/O and whenever there is a memory allocation failure or file I/O failure I just simply call a custom...
4
15806
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
5805
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 error: ------------------------------------ System.Security.SecurityException: The event source ExceptionManagerInternalException does not exist...
0
229
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
4164
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 user tasks should always be included in a try/catch block that actually handles any exceptions that occur (log the exception, display a message box,...
3
2499
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 me explain how my question is different. Second, let me say that I have two questions. One is an ASP.Net related question. The other is a general...
2
6965
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: parseMetadata.obj : error LNK2001: unresolved external symbol "public: __thiscall std::exception::exception(void)" (??0exception@std@@QAE@XZ)...
0
7393
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7653
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7411
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7749
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5965
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3439
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1871
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1012
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
695
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.