ThreadBoard ArchivesSite FeaturesActiveworlds SupportHistoric Archives |
AW SDK & .NET (C#) (Sdk)
AW SDK & .NET (C#) // SdkgrimbleMay 22, 2006, 10:11am
Until yesterday, I was blissfully unaware of a number of issues I had with
using the SDK under .NET (C#). Some VERY shy exceptions keeping themselves out of sight (System.Timers.Timer! GRRR!) meant I was missing some real problems with interfacing with the SDK. I think this list is going to grow, so I'll start with the three I've attached below. This is using .NET 1.1 (but the same happens in 2.0) and SDK Build 41. If anyone has experienced these before and/or has any constructive comments, I'd be grateful. Many thanks, Grims. ********** *** C# Callback Delegate ********** I have SDK callbacks being installed though the use of a delegate, as follows: public delegate void SDKCallbackHandler(int ReturnCode); This works great until the end of the delegate processing, when the application kicks out a null reference exception from within aw_wait(). It would seem not to be a GC'd delegate - .NET has a specific exception for GC'd delegates and all the delegate instances are static and within context. I get no such problems with the event delegates. ********** *** AW_CALLBACK_LOGIN/aw_login Return Code ********** Possibly related to the delegate issue above (only because its a callback), but when I install the AW_CALLBACK_LOGIN callback, aw_login() returns a 439 (No Connection). If I don't install the callback, it logs in fine. ********** *** aw_cell_next Return Code ********** This one is annoying. As I've done before in other languages, I have a query facility for a single cell using the aw_cell_next with a forced value for AW_CELL_ITERATOR. Generally this works fine, with the AW_EVENT_CELL_BEGIN, AW_EVENT_CELL_OBJECT and AW_EVENT_CELL_END events all being delivered and setting the attributes that would be expected. However, the return code for the aw_cell_next call is always 74 (No Such Cell). Its not my calculation for AW_CELL_ITERATOR, because I've tried setting it to zero (as per docs) and the same happens - the events are fired but it returns 74 and AW_CELL_ITERATOR is not incremented. andrasMay 22, 2006, 2:02pm
[View Quote]
<snip>
> ********** > *** aw_cell_next Return Code > ********** > This one is annoying. As I've done before in other languages, I have a query > facility for a single cell using the aw_cell_next with a forced value for > AW_CELL_ITERATOR. Generally this works fine, with the AW_EVENT_CELL_BEGIN, > AW_EVENT_CELL_OBJECT and AW_EVENT_CELL_END events all being delivered and > setting the attributes that would be expected. However, the return code for > the aw_cell_next call is always 74 (No Such Cell). Its not my calculation > for AW_CELL_ITERATOR, because I've tried setting it to zero (as per docs) > and the same happens - the events are fired but it returns 74 and > AW_CELL_ITERATOR is not incremented. > > This error exists only when you are trying to do it in AW. All other worlds seems fine. AW uses multiple ctree databases due to the sheer size and the iterator just don't work there with the "combine" feature. Set AW_COMBINE to false and it will work (of course it will be a cell by cell query). -- Andras "It's MY computer" (tm Steve Gibson) grimbleMay 22, 2006, 4:38pm
Thanks Andras. Yes it was in AW, but the value of AW_CELL_COMBINE doesn't
appear to make a difference - I get a 74 in either case. This isn't a major issue if its an AW only thing. I would assume that there won't be another world like AW with this complication, so for now I can work around it until I run it somewhere else. Thanks for the info. Grims. [View Quote] grimbleMay 23, 2006, 6:41am
I hope this doesn't turn into a thread of me talking to myself, but I've
found ONE solution that seems to solve the null reference exception. Having said that, its far from elegant (actually its a mess!) and I don't really want to use it, but it does confirm the problem - calling convention (although if that's the case then I'm surprised no-one else has hit it unless other .NET users are going through COM). Back in the days when I was using VB6, I created a new aw.dll from aw_static.lib and used this directly from VB6 without going through COM. I think that would probably be the best way to address this as well (its a shame I don't have the code anymore!). Its nothing difficult, just an amount of effort to put a prototype together. Once I've confirmed it works, if there's a demand for it from others then I'll redo it a little more neatly and tout it about. Again, any comments welcome. Grims. [View Quote] grimbleMay 24, 2006, 6:12am
The new DLL worked great - it can be called directly (and safely) from .NET
with appropriate prototypes. It may be a while before I get a chance to finish it and tart it up (or it may not), but I'll probably wait until the final 4.1 SDK is available so that it can support that release before I publish it. Grims [View Quote] > Back in the days when I was using VB6, I created a new aw.dll from > aw_static.lib and used this directly from VB6 without going through COM. grimbleMay 24, 2006, 6:15am
This one is is still a problem for me. Does anyone else suffer from this on
Build 41 (on any platform)? Grims [View Quote] grimbleMay 25, 2006, 5:54am
Last post on this. .NET 2.0 handles the calling convention issue with
callbacks by using an attribute on the delegate, so there's no need to worry about this afterall (unless you're like me and use .NET 1.1). |