Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 605971
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T17:12:15+00:00 2026-05-13T17:12:15+00:00

I’ve got an issue where i’m trying to call an object in spring.net through

  • 0

I’ve got an issue where i’m trying to call an object in spring.net through a ProxyFactoryObject. Now the the object that i’m calling in the factory has one constructor which takes in another object by reference through constructor injection. When i call the proxy from the c# code the correct target object is returned from the proxy but the items inside it that should be set to something through the initital constructor call are empty. Now i’m not sure why this is happening.

MY APP.CONFIG Objects section is below:

    <objects xmlns="http://www.springframework.net">

        <object name="MyMovieLister" id="MyMovieLister" type="SpringTestProgram.Classes.MovieLister, SpringTestProgram"  singleton="false">
            <!-- using cstor injection... -->
            <constructor-arg index="0" ref="MyMovieFinder"/>
            <constructor-arg index="1" value="2"/>
        </object>

        <object name="MyMovieFinder" id="MyMovieFinder" type="SpringTestProgram.Classes.MovieFinder, SpringTestProgram" singleton="false"/>

        <object id="MyBeforeAdvisor"
                type="Spring.Aop.Support.NameMatchMethodPointcutAdvisor, Spring.Aop">

            <property name="Advice">
                <object id="myBeforeAdvice"
                 type="SpringTestProgram.Classes.LoggingAdvice, SpringTestProgram"/>
            </property>

            <property name="MappedNames">
                <list>
                    <value>FindAll</value>
                </list>
            </property>
        </object>


        <object name="MovieWorkerProxy" type="Spring.Aop.Framework.ProxyFactoryObject, Spring.Aop">

             <property name="Target" ref="MyMovieLister" /> 

             <!--<property name="TargetSource">
                <object type="Spring.Aop.Target.PrototypeTargetSource, Spring.Aop">
                    <property name="TargetObjectName" value="MyMovieLister" />
                </object>
            </property>--> 

            <!--<property name="ObjectNames">
                <list>
                    <value>MyMovieLister</value>
                </list>
            </property>-->

            <property name="interceptorNames">
                <list>
                    <value>MyBeforeAdvisor</value>
                </list>
            </property>
        </object>      

    </objects>

And below is the c# code that i have to call this:

        IApplicationContext ctx = ContextRegistry.GetContext();
        MovieLister myMovieLister = ctx.GetObject("MovieWorkerProxy") as MovieLister;

        IList<string> myList = myMovieLister.FindMovies();

Now the actual implemention of the class is really not important but the only class that we are really concerned with here is listed below:

public class MovieLister 
{
    public MovieLister(IMovieFinder myMovieFinder, int i)
    {
        number = i;
        movieFinder = myMovieFinder;
    }

    public IList<string> FindMovies()
    {
        return movieFinder.FindAll();
    }

    private int number;
    private IMovieFinder movieFinder;         
}

Now i’m not sure why when i call the class above from my proxy factory do both of the fields that are set by the only constructor set to null ? Can anyone help……

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T17:12:16+00:00Added an answer on May 13, 2026 at 5:12 pm

    Short answer: Make number and movieFinder a property, add the virtual keyword to the properties and the FindMovies method and use the properties instead of the fields directly.

    Longer answer: It has to do with the way the proxy is constructed, take a look at Erich Eichingers’s blog on how Spring.NET creates proxies. Part 1, 2 and 3.

    And since you are proxying a class, take a look at the Spring.NET documentation, it indicates the problem with non virtual methods.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.