473,396 Members | 1,968 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,396 software developers and data experts.

Bug in framework 2.0

Hello,

I've tried to create a matching MMTIME struct in C# to pass to the
timeGetSystemTime DllImported method... here are my structs:

[StructLayout(LayoutKind.Sequential)]
public struct MMTIME
{
public uint wType;
[MarshalAs(UnmanagedType.Struct)]
public Union u;

[StructLayout(LayoutKind.Explicit)]
public struct Union
{
[FieldOffset(0)] public uint ms;
[FieldOffset(0)] public uint sample;
[FieldOffset(0)] public uint cb;
[FieldOffset(0)] public uint ticks;
[FieldOffset(0)] [MarshalAs(UnmanagedType.Struct)] public
SMPTE smpte;
[FieldOffset(0)] [MarshalAs(UnmanagedType.Struct)] public
MIDI midi;
}

[StructLayout(LayoutKind.Sequential)]
public struct SMPTE
{
public byte hour;
public byte min;
public byte sec;
public byte frame;
public byte fps;
public byte dummy;
public ushort pad;
}

[StructLayout(LayoutKind.Sequential)]
public struct MIDI
{
public uint songptrpos;
}
}

When I do:

Marshal.SizeOf(typeof(MMTIME.MIDI)); = 4
Marshal.SizeOf(typeof(MMTIME.SMPTE)); = 8
Marshal.SizeOf(typeof(MMTIME.Union)); I get:

Type 'Common.Structures.MMTIME+Union' cannot be marshaled as an
unmanaged structure; no meaningful size or offset can be computed.

I tried remarking from the Union struct, any 1 of the 2 structures
members, and when I remaked the MIDI structure, it passed the
Marshal.SizeOf.

on the other hand, if i Add to the MIDI structure another member (so
that the struct now contains more than 1 memebr) it also works,
example:

[StructLayout(LayoutKind.Sequential)]
public struct MIDI
{
public uint songptrpos;
public uint tmp;
}

my guess is a Marshal.SizeOf does not work on structs which contains
another struct with 1 member in it...

Best Regards,

Eyal Safran.

Jul 28 '07 #1
0 1066

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

Similar topics

0
by: Ravindra | last post by:
Well I installed the framework provided by microsoft , the problem is I am able to activate the smart tag in the doc file but when I Click on the Show Detils option in the information bridge the...
3
by: CMan | last post by:
Hi, We are currently trying to install .Net Framework v.1.1 on a server which already has v1.0. We are receiving the following error. Error 1704.An installation for Microsoft .NET Framework...
18
by: Cameron Laird | last post by:
QOTW: "... So I started profiling the code and the slowdown was actually taking place at places where I didn't expect it." -- Guyon Mor?e (and about twenty-three thousand others) " suggestion...
6
by: Joseph Geretz | last post by:
I recently upgraded my server to Windows 2003. The first thing I noticed is that my sample WebService pages no longer worked. The Invoke test button is missing. This is addresed by the following KB...
9
by: Tim D | last post by:
Hi, I originally posted this as a reply to a rather old thread in dotnet.framework.general and didn't get any response. I thought it might be more relevant here; anyone got any ideas? My...
1
by: Harry Simpson | last post by:
I know I drilled down into the Windows folder\Microsoft.net\Framework\v1.1.4322 folder and looked at the version of Mscorcfg.dll to get the SP level from the version number: Mine shows...
3
by: Shadow Lynx | last post by:
At the bottom of the default Error page that appears when Unhandled Exceptions occur, what exactly is the difference between the "Microsoft ..Net Framework Version" and the "ASP.NET Version"? I...
3
dmjpro
by: dmjpro | last post by:
plz send me a good link which can clearify me how the J2EE framework works i want the details information .... plz help thanx
13
by: dancer | last post by:
I have made a new post because when I try to respond to another, I get the error, "Article Rejected -- Ill-formed message id" This is in response to the advice of Juan Libre to install Net...
8
by: Blasting Cap | last post by:
I'm using VS 2005, and have a dll in some code (system.core.dll) that was included in something someone sent me to run on my system. I have production on a server using Framework 2.0 that I want...
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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...
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
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,...

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.