What could cause repeated InvalidOperationExceptions in I2cDevice's WriteRead()?

I keep getting the following exception when using an I2cDevice’s WriteRead() function.

An unhandled exception of type ‘System.InvalidOperationException’ occurred in GHIElectronics.TinyCLR.Devices.I2c.dll

Does anyone have any advice on what can cause this exception from this method?

In one project I’ve seen it only occur when I build a new version of the project (sometimes, not every time), and I there I am able to hackily solve it by rebuilding the project with a UART write added just before the I2C WriteRead, at which point the code would run happily. I could then remove the added UART write and rebuild to run successfully. This (running the same code with different results after making and correcting a change) felt like some kind of timing issue to me, but all of my code is running in a single thread, so I don’t understand where that kind of issue could come from… I doubt it would be an issue with the implementation of WriteRead itself.

In another project now the exception occurs on every WriteRead and I can’t find any way around it, so I’m forced to try to figure out what’s actually causing the issue.

As always, any help greatly appreciated!

Does it always raise invalid exception or just sometime?

if it is always then it could be invaild slave address, or you may need 2.2K pull up resistors.

Do you have any I2C analyzer?