Spring.net -- currently, getter and setter access delimiters are not supported.

Source: Internet
Author: User
If you use spring.net as your IOC container, be sure to pay attention to this problem. --spring.net currently does not support access qualifiers of getter and setter.
We usually use the setter attribute for dependency injection, for example, public Class.
{
# Region B
Private B;
Public B
{
Get {return B ;}
Set {B = value ;}
}
# Endregion
}

Public Class B
{
}

For the above definition, it is completely normal to configure a Class A object in spring.net and inject the dependency of Class B object.
However, suppose that I want the B attribute of the type to only access the derived class of a. We usually add the protected qualifier to the getter of the B attribute, just like this: Public Class
{
# Region B
Private B;
Public B
{
 ProtectedGet {return B ;}
Set {B = value ;}
}
# Endregion
}

Public Class B
{
}

In this definition, if the same spring configuration is still used, an exception "object reference is not set to object instance" is thrown-a very common exception.

What kind of pain is it when I look for possible bugs in applications composed of thousands of components following this exception prompt-in fact, my code and configuration are fine, spring.net made a joke. It took me nearly two hours to figure out the joke. So, I don't want your friends to waste our precious time in the future due to the same problem.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.