West Wind .NET Tools and Demos
OLE IDispatch exception code 0 from wwDotNetBridge: Index was outside the bounds of the array...
Gravatar is a globally recognized avatar based on your email address. OLE IDispatch exception code 0 from wwDotNetBridge: Index was outside the bounds of the array...
  Matthew Olson
  All
  Sep 14, 2023 @ 08:56am

Recently update wwDotNetBridge.dll and all of its dependencies. At least I think I got them all. And nothing is blocked. I've also got the exename.exe.config with the LoadRemoteResources in it (though, I am able to replicate the issue running the executable locally). Everything (email, interop with some DLLs I've created, JSON serializing, etc.) is working except for when doing spell checking. I'm not sure where I got the idea for doing this (I think Rick or Doug did a session at SWFox many years ago, but I can't find the session now).

Anyway, the error is in the post title. Line 691 of WWDOTNETBRIDGE.GETINDEXEDPROPERTY. That is called by Hunsspellchecker.suggest:

	FUNCTION Suggest(lcWord)
	LOCAL loWords, lnX
	loCol = CREATEOBJECT("collection")
	loWords = THIS.oBridge.InvokeMethod(THIS.oSpell,"Suggest",lcWord)
	lnCount = THIS.oBridge.GetProperty(loWords,"Count")
	FOR lnX = 0 TO lnCount -1
		lcWord = THIS.oBridge.GetIndexedProperty(loWords,lnX)
		loCol.ADD( lcWord )
	ENDFOR
	RETURN loCol
	ENDFUNC

The hunspell DLLs and whatnot date back to 2015. If there have been updates to them, I can't find them.

Thank you in advance for your time and advice. Let me know if you need any more information to help solve this one.

Thanks, Matthew Olson

Gravatar is a globally recognized avatar based on your email address. re: OLE IDispatch exception code 0 from wwDotNetBridge: Index was outside the bounds of the array...
  Rick Strahl
  Matthew Olson
  Sep 18, 2023 @ 07:30am

I took a look at my old demo and yeah I see the same issue with GetIndexedProperty().

I'm not sure why I was useing GetIndexedProperty() in this case because the following is much easier and cleaner to read:

FOR lnX = 0 TO lnCount -1
    *** We have to retrieve the indexed collection value
    * lcWord = this.oBridge.GetIndexedProperty(loWords,lnx)
    lcWord = loWords.Item(lnX)
    loCol.Add( lcWord )
ENDFOR

ComArray.Item() gets an indexed value out of a list collection.

There are also a number of new methods in the ComArray class that gets returned for collection instances that allow easier access to named keyed values in collections. See ComArray in the docs.

Still going to take a look why GetIndexedProperty() is not working though - it shouldn't be breaking like this since the array and index are obviously valid.

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: OLE IDispatch exception code 0 from wwDotNetBridge: Index was outside the bounds of the array...
  Matthew Olson
  Rick Strahl
  Sep 18, 2023 @ 07:43am

Thank you, Rick! That's working for me.

Gravatar is a globally recognized avatar based on your email address. re: OLE IDispatch exception code 0 from wwDotNetBridge: Index was outside the bounds of the array...
  Rick Strahl
  Matthew Olson
  Sep 18, 2023 @ 08:17am

Took a look at the GetIndexProperty() implementation and wow that was certainly not going to work.

Some internal changes in wwDotnetBridge related to ComArray usage and fixups was breaking that - basically that method is meant to be used on raw arrays and collection instances, not on existing ComArray instances. It was failing due to the ComArray passed in (which was a recent change in how some methods return collections by default).

IAC, it's fixed now - checks for the specific case of ComArray being passed in and if so just returns the item from the ComArray.Item() method.

Still odd that I would have used that particular method to access the list - I think I was trying to show different ways that you can do things with wwDotnetBridge, but it certainly was not the cleanest way in this case. ComArray.Item() definitely is the right way to retrieve a list item.

It'll be in the next round of updates.

+++ Rick ---

© 1996-2024