For those new to message boards please try to follow a few simple rules when posting your question.
Choose the correct forum for your message. Posting a VB.NET question in the C++ forum will end in tears.
Be specific! Don't ask "can someone send me the code to create an application that does 'X'. Pinpoint exactly what it is you need help with.
Keep the subject line brief, but descriptive. eg "File Serialization problem"
Keep the question as brief as possible. If you have to include code, include the smallest snippet of code you can.
Be careful when including code that you haven't made a typo. Typing mistakes can become the focal point instead of the actual question you asked.
Do not remove or empty a message if others have replied. Keep the thread intact and available for others to search and read. If your problem was answered then edit your message and add "[Solved]" to the subject line of the original post, and cast an approval vote to the one or several answers that really helped you.
If you are posting source code with your question, place it inside <pre></pre> tags. We advise you also check the "Encode "<" (and other HTML) characters when pasting" checkbox before pasting anything inside the PRE block, and make sure "Use HTML in this post" check box is checked.
Be courteous and DON'T SHOUT. Everyone here helps because they enjoy helping others, not because it's their job.
Please do not post links to your question into an unrelated forum such as the lounge. It will be deleted. Likewise, do not post the same question in more than one forum.
Do not be abusive, offensive, inappropriate or harass anyone on the boards. Doing so will get you kicked off and banned. Play nice.
If you have a school or university assignment, assume that your teacher or lecturer is also reading these forums.
No advertising or soliciting.
We reserve the right to move your posts to a more appropriate forum or to delete anything deemed inappropriate or illegal.
I am working on the correct usage of IOCContainer(Autofac) in a project which has mulitple assemblies. I am not able to understand the nested dependency pattern correctly as well as what would be the best exception handling strategy in case of failed resolves.
The post is not concise, as I am afraid I cannot explain my confusion in a brief manner. So apologies..
I am trying to use the 'constructor injection pattern' instead of 'property' or 'method' injection. so a class which looked like this:
privatestaticreadonly IDependency = IOCContainer.Resolve<IDependency>();
is changed to something like this
Class Foo(IDependency dependency)
privatereadonly IDependency = dependency;
however after cleaning up the whole code with the constructor pattern, the code looks like this
public Foo(IDependency dependency)
this.dependency = dependency;
var bar = new Bar(this.dependency);
public Bar(IDependency dependency)
this.dependency = dependency;
Now if the dependency was not available (IOCContainer failed to resolve this dependency), Foo will pass that dependency around, without worrying about the failed resolved call..
I think that given this scenario, the property or method injection methods seem correct as all the classes are directly calling IOCContainer resolves and then they would have a way to check if the dependency was resolved or not directly from the IOCContainer.
However A null check or a try catch can be applied when we access the dependency anyways even with the constructor injection pattern, for e.g.
(dependency != null ? dependency.doSomething : thrownew Exception(DependencyNotAvailable);
Is it correct approach? How should I handle the exceptions from IOCContainer otherwise?
I see some things in your code which I would change, and this should hopefully clear things up for you. Basically, you're mixing up IoC with newing stuff. If I were you, I would change the implementations to something like this:
As you can see, we're relying on injecting any dependencies here (i.e. injecting IBar rather than newing up Bar), and we test in the constructor for nulls. That way, we determine early on whether or not an actual implementation has been passed in.
PrivateSub cmbcustomer_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles cmbcustomer.SelectedIndexChanged
txtticketnumber.Text = "9" + Format(cmbcustomer.SelectedValue, "0000")
Catch ex As Exception
Hi to all.This Is Lakshmi Dhivya,Iam doing my Engineering on Information Technology(IT),and I have decided to make an editor with all possible formatting options.
I have selected vb.net as a programming language for my project.
I have started designing the Rich Text editor,but Iam unable to change the font size alone with different font text selected.I have added a font comobox and a size combobox,but i need to change font alone and size alone with different font text selected.
You have not really explained what the problem is. If you select a new font from the font combo then the current font size should be used. And if you select a new height then the current font should be used. Alternatively you could use the FontDialog class[^].
You have to create a new Font object, based on the previous font object, with the new FontSize. That's the bad thing with Fonts: they are immutable, and changing a property of a font can only be done be creating a new one with the different property.
I have found that in wordpad if you select a text content typed in different fonts the font combobox will not show any font and if you change the size, only the size of the selected text changes and not the fonts.
How To do this.
This Is my Problem,I think i have told the exact problem.
Awaiting positive response form you all.
Last Visit: 31-Dec-99 18:00 Last Update: 16-Mar-14 14:44