Daklu Posted February 24, 2012 Report Share Posted February 24, 2012 I'm using a custom .Net api on a current project, and for reasons that are too lengthy to explain I've resorted to using a typecast to change a .Net reference wire from one .Net object type to a different, but similar .Net object type. (Property nodes have similar fields, but in a different order.) It works okay while smoke testing, but I'm not very comfortable with it at all. I don't know the underlying mechanics of how LV maps property nodes to .Net accessors, leaving me wondering what kinds of failures I'm likely to see. Anyone have insight they'd like to share? Quote Link to comment
asbo Posted February 24, 2012 Report Share Posted February 24, 2012 I'm surprised that it even works at all, since the properties are in a different order. I take that to mean LV maps its property nodes in a somewhat intelligent way, but for speed's sake, I hope it's not via reflection... My expectation would be access violations, or corrupted data at the very least. You are both reading and writing? Quote Link to comment
Daklu Posted February 24, 2012 Author Report Share Posted February 24, 2012 Yep, reading and writing. Quote Link to comment
mje Posted February 25, 2012 Report Share Posted February 25, 2012 Also surprised it works at all, my guess is if you tried calling any methods on the refnum you'd see fireworks. I take it these objects are unrelated, so you can't do proper dynamic casts via the to more specific primitive? Quote Link to comment
Daklu Posted February 26, 2012 Author Report Share Posted February 26, 2012 (edited) I take it these objects are unrelated, so you can't do proper dynamic casts via the to more specific primitive? I don't really know how they are related as I don't have access to the .Net source code. If I were to guess I would say they might be siblings, but they're actually interfaces--not concrete classes--and they may not be in any sort of inheritance hierarchy. Here's a snippet showing the full property nodes before and after the typecast. Oddly, the SteppedLevelGenerator property node (before typecasting) always returns error 1172 while the FrequencySweepGenerator node (after typecasting) does not. [Grrr... my premium membership incorrectly expired and I'm over the freebie upload quota. I'll try to upload it once I get my membership sorted out.] Edited February 26, 2012 by Daklu Quote Link to comment
candidus Posted February 27, 2012 Report Share Posted February 27, 2012 I don't really know how they are related as I don't have access to the .Net source code. If I were to guess I would say they might be siblings, but they're actually interfaces--not concrete classes--and they may not be in any sort of inheritance hierarchy. You might be able to get information about their relationship without source code. Use IL disassembler (ildasm.exe) that ships with the .NET SDK. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.