Page 1 of 1

Creating objects like Noesis.Button directly within C#

Posted: 15 Oct 2013, 15:50
by Andreas Schooll
Hi,

we have a few cases in our project where we directly create objects like a Noesis Button or StackPanel directly in our C# code.

The code looks something like this:
//
Button objButton = new Button().

objButton.SetContent("text bla bla");
//

With 1.0.4 this worked without problems. Unfortunately with 1.1.0 there is an access violation occuring inside the called functions like SetContent(). As far as i have seen there is a new default constructor added in the proxies like Button.cs. And i guess it creates the object in the wrong address space (outside the dll) if we do it as we did?

What is the correct approach to create a Noesis UiElement within c# code?

best regards,
Andreas

Re: Creating objects like Noesis.Button directly within C#

Posted: 15 Oct 2013, 16:50
by sfernandez
The code you posted is the right way to create a Button programmatically. Unfortunately I was unable to reproduce this crash.

Would you mind posting here a simple xaml and script that causes you an access violation so we can try to track down the bug?

Thanks for your collaboration.

Re: Creating objects like Noesis.Button directly within C#

Posted: 15 Oct 2013, 17:54
by Andreas Schooll
We found the problem that was causing this behaviour.

We had some UserControls that where not using the new conventions and still had contructors as described in the 1.0.4 UserControl Tutorial. After creating such a user control we could not create / access manually created Ui elements.

Thanks for your help.

Re: Creating objects like Noesis.Button directly within C#

Posted: 15 Oct 2013, 18:03
by sfernandez
That is a relief :D