Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / CLR / November 2005

Tip: Looking for answers? Try searching our database.

"ldelema [mscorlib]System.Byte" failed on some circumstances

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Luc Vaillant - 16 Nov 2005 10:45 GMT
First of all, I'm using .Net Framework v1.1 with VS.NET 2003

I have made some tests, and I realized that "ldelema [mscorlib]System.Byte"
doesn't work on my Pocket PC device if my buffer is declared as follow even
if typeof(buffer) is Byte[]:

SetDouble(class [mscorlib]System.Array buffer,...

It does work if the buffer is declared as follow:

SetDouble(unsigned int8[] buffer,...

Here is the code of my method. It works on Win32 and Compact Framwork in the
emulator, but not on my Pocket PC device

   .method public hidebysig static void
           SetDouble(class [mscorlib]System.Array buffer,
           // SetDouble(unsigned int8[] buffer,
                     int32 offset,
                     float64 'value') cil managed
   {
    .locals (int32 nIndex, unsigned int8* pValue, unsigned int8* pBuffer)
       
    ldc.i4.0            // 0
    stloc.0            // nIndex = 0
   
    ldarga.s    2        // &value
    stloc.1            // pValue = &value;
       
    ldarg.0            // buffer
    ldarg.1            // offset
    ldelema [mscorlib]System.Byte    // &buffer[offset]
    stloc.2            // pBuffer = &buffer[offset]
   
LOOP:
    ldloc.2            // pBuffer
    ldloc.0            // nIndex
    add            // pBuffer + nIndex
    ldloc.1            // pValue
    ldloc.0            // nIndex
    add            // &pValue[nIndex]
    ldind.i1            // pValue[nIndex]
    stind.i1            // pBuffer[nIndex] = pValue[nIndex]
       
    ldloc.0            // nIndex
    ldc.i4.1            // 1
    add            // nIndex++
    stloc.0            // ->nIndex
   
    ldloc.0            // nIndex
    ldc.i4.8            // 8
    blt.s    LOOP        // if (nIndex < 8) goto LOOP
   
    ret
   } // end of method Buffer::SetDouble
John Perks and Sarah Mount - 16 Nov 2005 17:42 GMT
> ldelema [mscorlib]System.Byte // &buffer[offset]

What about if you replace this with

ldelema unsigned int8

?

I seem to recall that full names for primitives shouldn't be used

From ECMA 335:

"22.2.15 Short Form Signatures
The general specification for signatures leaves some leeway in how to
encode certain items. For example, it
appears legal to encode a String as either
long-form: ( ELEMENT_TYPE_CLASS, TypeRef-to-System.String )
short-form: ELEMENT_TYPE_STRING
Only the short form is valid. The following table shows which
short-forms should be used in place of each
long-form item. "

The table then lists System.Byte's shortform as U1, which corresponds to
unsigned int8.

On this subject (sort of) is it guaranteed to work that if you have the
following:

il.Emit(Opcodes.Unbox, aType);
il.Emit(Opcodes.Ldobj, aType);

even if aType is a primitive (so one could have used, e.g.
Opcodes.Ldind_u1), or an enum? If aType were an enum, to what extent
could one swap it with its underlying type (or the Ldind_* shorthand for
that type) in the above code?

Thanks

John
Luc Vaillant - 17 Nov 2005 06:56 GMT
> What about if you replace this with
>
> ldelema unsigned int8
LVT : It works on the emulator but not on the device (like ldelema
[mscorlib]System.Byte)

Thanks

> > ldelema [mscorlib]System.Byte // &buffer[offset]
>
[quoted text clipped - 35 lines]
>
> John

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.