2

Hello i have some problem with my Castle windsor project.

When im trying to pass some parameters by these method:

container.Resolve<ILogin>(new { Login = textBox1.Text, password =textBox2.Text });

the values of Login and password are set only once. Next, when im changing textbox values, and click on button once again, the values of login, and password are still the same. How can i change these parameters? Thank you

1 Answer 1

2

I bet your implementation of ILogin is registered on the container as a singleton, therefore the construction is happening only once. When you Resolve() the second time, it's already constructed and the values are fixed. Try changing it to .Transient instead. Look "Windsor lifestyles" up if you need more info on how to do that.

Btw, using the "container" directly is usually an indication of something wrong, design wise. Sometimes there are no other way, so take this comment with a pinch of salt.

2
  • Thank you, its working but i have different problem now.. I need to have one component that contains my two components. And when im trying to do this by this way: container.Resolve<Logging>("LogUser").logging.Login(); i have exception: " Can't create component 'LogUser' as it has dependencies to be satisfied."
    – Milan90
    Commented Mar 28, 2017 at 13:26
  • In details of these exception, i see that parameters to that two components, from which the "MAIN" component is built, was not provided.
    – Milan90
    Commented Mar 28, 2017 at 14:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.