In-field-update and System.ArgumentException

Hi Forum-users,

at first i must say i´m relatively new in coding in C# (formerly only coding in C) and in working with visual studio and NETMF. In the past i worked with STM controllers and used truestudio for coding…
I work with a G400 Dev board and visual studio 2013 (NETMF Framework version 4.3).
I try to get running an in-field-update based on the manual from GHI. (
At first i get the data for the update per FTP-Client and put it into a LargeBuffer-bytearray. (I tried to manage this via a filestream but couldn´t get that running.) For the FTP client i used the code from and adapted it to my project. So thanks to Clylloff for sharing the code :wink: (i am also new in everything that has to do with FTP ::slight_smile: )
Now i have the new firmware in my LargeBuffer (1.1MB) and want to use the in-field-update routine “LoadFile” to load it into the RAM. But unfortunately i get a System.ArgumentException. I adapted the function in this way:

public static void LoadFile(LargeBuffer source, InFieldUpdate.Types type)
            using (var stream = new MemoryStream(source.Bytes))
                var data = new byte[BLOCK_SIZE];

                for (int i = 0; i < stream.Length / BLOCK_SIZE; i++)
                    stream.Read(data, 0, BLOCK_SIZE);
                    InFieldUpdate.Load(type, data, BLOCK_SIZE);

                stream.Read(data, 0, (int)stream.Length % BLOCK_SIZE);
                InFieldUpdate.Load(type, data, (int)stream.Length % BLOCK_SIZE);

Can´t the InFieldUpdate.Load method handle LargeBuffer? In my opinion it is also only a byte array. :think:
I can´t figure out what the problem is. And i can´t find a documentation for the in-field-update class or the methods. Has someone a link for the documentation.
If you have any hints what i can do or know a running project for updating the G400 board per net than please tell me :slight_smile:

kind regards


Which statement are you observing the “System.ArgumentException” from?

There is a possibility that the InFieldUpdate.Load size parameter could be zero, not sure Load would accept a value of zero, you might want to check that parameter when you get an execption.

We use IFU but with a byte array and the size in a single statement.


Hi Phil,

thanks for your reply.
The System.ArgumentException occurs at the first call of InFieldUpdate.Load in the for-loop.
The size is defined as

and the value is correctly passed during debugging. 

I also tried to use the InFieldUpdate.Load in a single statement like this:

```cs]InFieldUpdate.Load(InFieldUpdate.Types.Firmware, firmware.Bytes, filesize);[/code

where firmware.Bytes is my LargeBuffer and filesize is the size of the whole firmware-file -> 1.1MB.

When i use this i get the following message:

An Exception error of type "System.ArgumentException" has occurred in GHI.Hardware.dll

(Ein Ausnahmefehler des Typs "System.ArgumentException" ist in GHI.Hardware.dll aufgetreten.)

So this doesn´t work for me too. :(

I´m not sure but i think the LargeBuffer is the problem for the GHI.Hardware.dll :think:


The only other thing that I can think of is you first need to make a call to Initialize the InFieldUpdate class before calling the Load method.



Hi Phil,

i´ve tried that too and that didn´t solve the problem.

I now changed the code in that way that it is even a normal byte[] buffer with a size like in the example code from GHI.

count = dataSocket.Receive(ftp_buffer, BLOCK_SIZE, SocketFlags.None);
InFieldUpdate.Load(InFieldUpdate.Types.Firmware, ftp_buffer, count);

But this still doesn´t work and i get a System.ArgumentException from the GHI.Hardware.dll

The reference to GHI.Hardware is in the project and i am using the directive GHI.Processor.

I can´t figure out what i´m doing wrong. :frowning:

@ r.albat - I would start with the example we provide in the IFU document. Load the firmware and application from an SD card to verify that IFU works for you with your files. Then try to convert the code to use FTP.

1 Like

Ok, i´ll try that and i hope i get it this way round working.


Any update on this please? I am struggling with the same error, for COBRA III

you should follow the same advice - and then if you still fail start your own thread documenting your own error(s)