Netduino home hardware projects downloads community

Jump to content

The Netduino forums have been replaced by new forums at This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.

An unhandled exception of type 'System.Exception'

  • Please log in to reply
1 reply to this topic

#1 andrewxxx


    New Member

  • Members
  • Pip
  • 1 posts

Posted 08 March 2015 - 06:09 PM

i'm working on a finger print module, the compiler throw me an unhandled exception with no details or data for what's wrong

An unhandled exception of type 'System.Exception' occurred in Project Intersect.exe


        public static implicit operator byte[](CommandPacket packet)
            var buffer = new byte[52];
            fixed (byte* ptr = buffer)
                *((ushort*)(ptr)) = (ushort)packet.PacketID;
                *((ushort*)(ptr + 2)) = (ushort)packet.Subtype;
                *((ushort*)(ptr + 4)) = packet.Length;
                for (var i = 0; i < 16; i++)
                    *(ptr + 6 + i) = packet.Data[i];
                *((ushort*)(ptr + 22)) = packet.CheckSum;
            return buffer;
it throws the exception at *((ushort*)(ptr)) = (ushort)packet.PacketID; (yeah i did try to comment this one as maybe it could be the enum casting that causes this problem but still same exception on the next line)
so what's wrong ? any alternatives ?

#2 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 11 March 2015 - 06:31 PM

Hi andrewxxx,

Technically NETMF doesn't officially support unsafe code. I've seen people use it--and it won't necessarily *not* work, but I'd recommend assigning the values one byte at a time (using bitmasks and bit shifting).

Welcome to the Netduino community,


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.