Jump to content
The simFlight Network Forums

IndexOutOfRangeException when calling Process()


Recommended Posts

Hi Paul,

BLUF: Any idea what would cause Process() to generate IndexOutOfRangeException?

Whenever I call Process(), I get the following error. The code (reads and writes) has been working perfectly for months, then this error started a few days ago, and I can't figure out what changed to cause this. I still get a successful fsuipc connection, but the reads/writes no longer sync properly to P3D (Presumably because of the error below). 

Exception thrown: 'System.IndexOutOfRangeException' in FSUIPCClient.dll
System.IndexOutOfRangeException: Index was outside the bounds of the array.
   at FSUIPC.FSUIPCConnection.Process(Byte ClassInstance, IEnumerable`1 GroupNames)
   at FsuipcSdk.Fsuipcx.Process() in C:\Users\airpa\fsuipcx.cs:line 285

Line 285 is below:

public bool Process ()
        {
            if (FSUIPCConnection.IsOpen)
                FSUIPCConnection.Process(); // Line 285

            return true;
        }

Any thoughts are greatly appreciated,

Robert

Link to comment
Share on other sites

Hi Robert,

It's difficult to tell from that error.

What version of the DLL are you using?

Can you make sure you have the fsuipcClient.pdb file in the folder you run your application from. This should make it so the line number from my DLL is reported in the stack trace. That would help a lot. Visual Studio usually copies the pdb file to the build folder (e.g. bin/release).

Paul

Link to comment
Share on other sites

Paul,

DLL Version is 3.1.9.311. fsuipcClient.pdb isn't in the folder, and I can't find it on my system. Also tried downloading from your site (application templates), but can't seem to find it. Where can I find it?

Thanks,

Robert

Link to comment
Share on other sites

That's a very old version (about 4 years). Back then I was not shipping the pdb files in the package. The pdb files are specific to each build of the DLL so I can't generate one for an old version.

I can only really suggest updating to the latest version.  There could be a few breaking changes however, depending on what features you're using.

Also, the earliest framework supported is now .NET Framework 4.6.2. If you're using an earlier framework and don't want to upgrade your project to a new framework, let me know what version you're targeting. I might be able to suggest an alternative version of the DLL that supports the framework you're using.

Paul

Link to comment
Share on other sites

The pdb files don't seem to be in the latest packages either. I'll have to sort that out. But at least I can attach a copy for the latest version. I'll need to know which framework version you're using though - 4, 5, 6 or 7.

Paul 

Link to comment
Share on other sites

Thank you; .NET Framework is 4.8.

Just wondering... does it have anything to do with target platform, or anything similar? I'm targeting x64, but have also tried x86 and Any CPU, with similar results.

Also, since upgrading, I'm now getting a second error from Process():

Exception thrown: 'System.IndexOutOfRangeException' in fsuipcClient.dll
Exception thrown: 'System.Exception' in fsuipcClient.dll
 

Robert

Link to comment
Share on other sites

Thanks Paul, here's what I get:

System.IndexOutOfRangeException: Index was outside the bounds of the array.
   at FSUIPC.FSUIPCConnection.Process(Byte ClassInstance, IEnumerable`1 GroupNames) in C:\Dev\FsuipcClient\fsuipcClient\fsuipcClient\fsuipcConnection.cs:line 707

Link to comment
Share on other sites

That line number doesn't really help unfortunately. Can you make sure FSUIPCConnection.DLLVersion is reporting 3.3.8?

Also some of this info might help:

1. are you using any named offset groups anywhere in your application? Or are you just using the blank default group?

2. is there any multi-threading in your application? Or is everything run on the main UI thread?

Paul

Link to comment
Share on other sites

Paul, I truly appreciate your help, but decided to roll back to an earlier build from before the problem happened. It's about 30 days old, but seems like it will be easier to re-stitch the changes, than trying to find the "needle in a haystack" issue that led to this. I changed something somewhere that caused this to break, as it's been working perfectly for quite some time, but can't figure out what the change was. I'm still curious, so I don't break it again, but for the moment, the blocker is averted. I'll keep you posed if the problem becomes revealed as I'm re-stitching the updates.

You're super responsive; I truly appreciate it!

Thanks,

Robert

  • Like 1
Link to comment
Share on other sites

Wow...I FINALLY found the needle in the haystack... mainly while typing up my findings to you, Paul

I finally figured out this was an issue caused by writing to FLOAT64 variables. In my app, in the length fields, I use length 9 to differentiate between Int64 and Float64 (both length 8). I do the same thing with length 5 for Float vs. Int32 (both length 4). When initializing the offset, I didn't realize I was passing the length 9 to your module, when instead, I should have been converting 9 to 8 and 5 to 4 before initializing the offset.

This issue has always been there... but looks like I hadn't been using any FLOAT64 variables. So offset initialization didn't even occur in my mind as a possibility. I ironically, the reads work fine, especially since battery voltage is only 2 digits.

Man... this is one of those bugs I need a strong beverage after.............

I really appreciate your help Paul. Talking through it was a big help, and made me look at things from angles I hadn't considered. Thank you!

Robert

  

Link to comment
Share on other sites

Great! Glad it's all sorted. It was baffling me for sure. I hadn't considered you were using the untyped Offset class. 

I've reproduced the error here and I've made a small change to the DLL so that it gives a much better exception than "index out of range":

FSUIPC.FSUIPCException: 'FSUIPC Error #999: FSUIPC_ERR_WRITE_OVERFLOW. Offset 66C0 is declared with length of 9 Bytes. 
The data you are trying to write is different from this. (8 bytes)'

Version 3.3.9 is now on NuGet.

Paul

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.