Notifications
Clear all

[Closed] Errors accessing dotNet properties

 PEN

I keep getting errors accessing dotNet properties.

They are very random but are cropping up more and more as I build this tool.

What I will get are error message that say things like

Unknown property: "location" in dotNetObject:System.Windows.Forms.Form

If it just tried again it works fine. Is there something that I need to check to see if every thing is up to date at that point in the script? I don’t want to start wrapping try()catch() around everything.

6 Replies
1 Reply
(@denist)
Joined: 1 year ago

Posts: 0

could you give a sample code shows this issue?

 PEN

It isn’t possible that is the problem. I’m getting it all over the place but it is completely random.

If you look at the error it makes no sense at all as a form has a location property. I get it on labels and other controls as well as it is trying to call controls.add and it says that the controls.add is not valid.

Let me see what I can come up with.

 PEN
>> MAXScript Rollout Handler Exception: -- Runtime error: No method found which matched argument list <<

That is the error when it is trying to call the .add method. Note that this is only some times. The function will work 20 times and then crap out, then work another 20.

1 Reply
(@denist)
Joined: 1 year ago

Posts: 0

it’s a memory overwrite issue… i’m 100% sure … probably the function corrupts some chunk of memory.

If it is memory corruption you might try sprinkling in calls to the .NET garbage collector to see if you can catch the problem.

dnGC = dotnetclass “GC”
gcForced = (dotnetclass “GCCollectionMode”).Forced

then

dnGC.Collect dnGC.MaxGeneration gcForced

I’ve encountered problems setting properties of .NET objects that I declared as dotNetControls. Its never intermittent like you describe though, it either works, or it doesn’t.

For example, trying to the set the ImageList property of a TreeView failed when the TV was hosted as a dotNetControl, but worked when I created it as a dotNetObject.

I’d see a message like “can’t convert dotNetObject:System.Windows.Forms.ImageList to System.Windows.Forms.ImageList” –wierd!

 PEN

Well it sounds like the same sort of thing how ever. I will give your solution a try. I have been using dngc.collect but not the rest of what you have posted. I will have a look at what you have there. I think that you are right Dennis, sounds like if could be over writing and then getting confused along the way.