Problem with virtual method

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jon Davis

    #1

    Problem with virtual method

    If I have a class with a virtual method, and a child class that overrides
    the virtual method, and then I create an instance of the child class AS A
    base class...

    BaseClass bc = new ChildClass();

    .... and then call the virtual method, why is it that the base class's method
    is called instead of the overridden method? How do I fix this if I don't
    know at runtime what the child class is? I'm using
    Activator.Creat eInstance() to load the child class from a satellite DLL, a
    third-party plug-in that inherits my base class, so I therefore cannot
    declare the child class type in the code or at compile time.

    Thanks,
    Jon


  • Jon Davis

    #2
    Re: Problem with virtual method

    But did you try it with a satellite DLL instantiated with
    Activator.Creat eInstance()?

    Otherwise we're just proving the difference between an overridden virtual
    method and the "new" keyword, that overriding works.

    Honest to God, though, my child class in an another DLL is overriding my
    virtual method, and the base virtual method is being called. I'm stepping
    through the code, and the base class comes up in the code window on that
    method. It is definitely marked as "virtual". The child class is definitely
    a child (public class MyChild : MyBase), and the method definitely has the
    "override" keyword.

    This has had me stumped for at least a week, and I CANNOT afford to lose
    another day on this project!! I MUST move on! But this plug-in feature is
    one of the core highlights of the product.

    What the hell is going on?? :( :(

    Jon


    "Alien" <alien@sympatic o.ca> wrote in message
    news:ugrSa.8150 $2h1.184@news02 .bloor.is.net.c able.rogers.com ...[color=blue]
    > That is odd
    > I've replicated what (I think) you're doing, and in my case the overriden
    > method is called. This is what I have:
    >
    > public class Test {
    > public virtual void testVoid() {
    > Console.WriteLi ne("base void!");
    > }
    > }
    >
    > public class TestChild : Test {
    > public override void testVoid() {
    > Console.WriteLi ne("child void!");
    > }
    > }
    >
    > In another class, I have:
    >
    > Test t = new TestChild();
    > t.testVoid();
    >
    > And the output I get is:
    > child void!
    >
    > "Jon Davis" <jon@REMOVE.ME. PLEASE.jondavis .net> wrote in message
    > news:uFNnLcnTDH A.2256@TK2MSFTN GP11.phx.gbl...[color=green]
    > > If I have a class with a virtual method, and a child class that[/color][/color]
    overrides[color=blue][color=green]
    > > the virtual method, and then I create an instance of the child class AS[/color][/color]
    A[color=blue][color=green]
    > > base class...
    > >
    > > BaseClass bc = new ChildClass();
    > >
    > > ... and then call the virtual method, why is it that the base class's[/color]
    > method[color=green]
    > > is called instead of the overridden method? How do I fix this if I don't
    > > know at runtime what the child class is? I'm using
    > > Activator.Creat eInstance() to load the child class from a satellite DLL,[/color][/color]
    a[color=blue][color=green]
    > > third-party plug-in that inherits my base class, so I therefore cannot
    > > declare the child class type in the code or at compile time.
    > >
    > > Thanks,
    > > Jon
    > >
    > >[/color]
    >
    >[/color]


    Comment

    • Jon Skeet

      #3
      Re: Problem with virtual method

      Jon Davis <jon@REMOVE.ME. PLEASE.jondavis .net> wrote:[color=blue]
      > If I have a class with a virtual method, and a child class that overrides
      > the virtual method, and then I create an instance of the child class AS A
      > base class...
      >
      > BaseClass bc = new ChildClass();
      >
      > ... and then call the virtual method, why is it that the base class's method
      > is called instead of the overridden method? How do I fix this if I don't
      > know at runtime what the child class is? I'm using
      > Activator.Creat eInstance() to load the child class from a satellite DLL, a
      > third-party plug-in that inherits my base class, so I therefore cannot
      > declare the child class type in the code or at compile time.[/color]

      I suspect you haven't overridden the method properly. Could you post a
      short but complete example which demonstrates the problem? See
      http://www.pobox.com/~skeet/csharp/complete.html for what I mean.

      --
      Jon Skeet - <skeet@pobox.co m>
      Pobox has been discontinued as a separate service, and all existing customers moved to the Fastmail platform.

      If replying to the group, please do not mail me too

      Comment

      • Jon Davis

        #4
        Re: Problem with virtual method

        "Jon Skeet" <skeet@pobox.co m> wrote in message news:MPG.198453 aee61d370c98a16 c@news.microsof t.com...

        [color=blue]
        > I suspect you haven't overridden the method properly. Could you post a
        > short but complete example which demonstrates the problem? See
        > http://www.pobox.com/~skeet/csharp/complete.html for what I mean.[/color]

        You already said this and gave that link in a prior thread. No I can't because I don't know how to reproduce the problem without displaying all of my code.

        Here's exactly what I have, with class, instance, and object names changed for the group:

        IN ASSEMBLY A:

        // name changed for group
        public abstract class MyType {

        ...

        // THIS IS WHERE THE DEBUGGER GOES WHEN STEPPING THROUGH THE CODE
        // name, return type name changed for group
        public virtual MyResultType MyMethod( ... ) {

        .. default output ..

        }

        }

        // name changed for group
        public class MyCallingType {

        // name, return type name changed for group
        public MyResultType[] MyActions( ... ) {

        ...

        // type names, names changed for group
        MyTypeInstanceL ist myTypeInstances = Thing.MyLoadedE xternalPlugIns;

        ...

        for (int i=0; i<myTypeInstanc es.Count; i++) {



        // type name, name changed for group
        MyType myTypeInstance = myTypeInstances[i];

        // NOTE THAT AT THIS POINT THE DEBUGGER
        // SAYS THAT THIS IS A MyNewType (see below)

        ...

        // type name changed for group
        MyResultType pr;

        ...

        pr = myType.MyMethod ( ... );

        ...


        }

        }
        }


        IN ASSEMBLY B:

        // names changed for group
        public class MyNewType : MyType {

        ...

        // THIS IS WHERE THE DEBUGGER SHOULD BE GOING
        // WHEN STEPPING THROUGH THE CODE
        // name, return type name changed for group
        public override MyResultType MyMethod( ... ) {

        ...

        }

        }



        Jon

        Comment

        • Jon Davis

          #5
          Re: Problem with virtual method

          This is how I'm instantiating the customized type ("MyNewType" ) from Assembly B...

          assem = System.Reflecti on.Assembly.Loa dFile(fn);

          ....

          Type t = assem.GetType(c lrName);

          ....

          MyTypeDescripto r ptd = new MyTypeDescripto r(t, vers, name, desc, longDesc);

          ....

          typeInstance = (MyType)Activat or.CreateInstan ce(
          ptd.Type, new object[] {thing, myTypeNode});


          Jon
          "Jon Davis" <jon@REMOVE.ME. PLEASE.jondavis .net> wrote in message news:eliPLRpTDH A.2128@TK2MSFTN GP12.phx.gbl...
          (Ignore previous [cancelled] reply...)


          "Jon Skeet" <skeet@pobox.co m> wrote in message news:MPG.198453 aee61d370c98a16 c@news.microsof t.com...[color=blue]
          > I suspect you haven't overridden the method properly. Could you post a
          > short but complete example which demonstrates the problem? See
          > http://www.pobox.com/~skeet/csharp/complete.html for what I mean.[/color]
          You already said this and gave that link in a prior thread. No I can't because I don't know how to reproduce the problem without displaying all of my code.

          Here's exactly what I have, with class, instance, and object names changed for the group:

          IN ASSEMBLY A:

          // name changed for group
          public abstract class MyType {

          ...

          // THIS IS WHERE THE DEBUGGER GOES WHEN STEPPING THROUGH THE CODE
          // name, return type name changed for group
          public virtual MyResultType MyMethod( ... ) {

          .. default output ..

          }

          }

          // name changed for group
          public class MyCallingType {

          // name, return type name changed for group
          public MyResultType[] MyActions( ... ) {

          ...

          // type names, names changed for group
          MyTypeInstanceL ist myTypeInstances = Thing.MyLoadedE xternalPlugIns;

          ...

          for (int i=0; i<myTypeInstanc es.Count; i++) {



          // type name, name changed for group
          MyType myTypeInstance = myTypeInstances[i];

          // NOTE THAT AT THIS POINT THE DEBUGGER
          // SAYS THAT THIS IS A MyNewType (see below)

          ...

          // type name changed for group
          MyResultType pr;

          ...

          pr = myTypeInstance. MyMethod( ... );

          ...


          }

          }
          }


          IN ASSEMBLY B:

          // names changed for group
          public class MyNewType : MyType {

          ...

          // THIS IS WHERE THE DEBUGGER SHOULD BE GOING
          // WHEN STEPPING THROUGH THE CODE
          // name, return type name changed for group
          public override MyResultType MyMethod( ... ) {

          ...

          }

          }



          Jon

          Comment

          • Jon Skeet

            #6
            Re: Problem with virtual method

            Jon Davis <jon@REMOVE.ME. PLEASE.jondavis .net> wrote:[color=blue]
            > (Ignore previous [cancelled] reply...)[/color]

            Too late - but see my reply to it.
            [color=blue]
            > // THIS IS WHERE THE DEBUGGER GOES WHEN STEPPING THROUGH THE CODE[/color]

            Have you tried running the code in release mode? Maybe it's just a
            debugger bug.

            --
            Jon Skeet - <skeet@pobox.co m>
            Pobox has been discontinued as a separate service, and all existing customers moved to the Fastmail platform.

            If replying to the group, please do not mail me too

            Comment

            • Jon Skeet

              #7
              Re: Problem with virtual method

              Jon Davis <jon@REMOVE.ME. PLEASE.jondavis .net> wrote:[color=blue]
              > This is how I'm instantiating the customized type ("MyNewType" )
              > from Assembly B...[/color]

              That doesn't really help me until I can run the code. I've managed to
              whip up a version which *does* work (see another post) - find out the
              differences between that and your code. There's really nothing else I
              can do without actually having some of your code in a form I can
              compile and run directly.

              --
              Jon Skeet - <skeet@pobox.co m>
              Pobox has been discontinued as a separate service, and all existing customers moved to the Fastmail platform.

              If replying to the group, please do not mail me too

              Comment

              • Jon Skeet

                #8
                Re: Problem with virtual method

                Jon Davis <jon@REMOVE.ME. PLEASE.jondavis .net> wrote:[color=blue]
                > "Jon Skeet" <skeet@pobox.co m> wrote in message
                > news:MPG.19845e 59d982c86598a17 1@news.microsof t.com...[color=green]
                > > Have you tried running the code in release mode? Maybe it's just a
                > > debugger bug.[/color]
                >
                > Ah, a helpful, insightful answer that doesn't involve your copy-pasting into
                > the debugger (which I can do)!
                >
                > Actually, this answer made me realize that files were not being properly
                > propogated to the proper directories upon compile. Hopefully that's my
                > problem, still testing ...
                >
                > (As I said, there was no more source code to demonstrate my problem. ;)[/color]

                But there was - if you'd posted a short but complete example which
                *wasn't* working on your box, I could have tried it and said whether or
                not it worked on *my* box. We'd then have seen that the code worked on
                one machine and not another, and that therefore it probably wasn't the
                code that was the problem, but the manner of running it.

                It's absolutely *crucial* that everyone ends up looking at the same
                code in this kind of thing.

                --
                Jon Skeet - <skeet@pobox.co m>
                Pobox has been discontinued as a separate service, and all existing customers moved to the Fastmail platform.

                If replying to the group, please do not mail me too

                Comment

                • Jon Davis

                  #9
                  Re: Problem with virtual method


                  "Jon Skeet" <skeet@pobox.co m> wrote in message
                  news:MPG.198465 fd1704ef6598a17 5@news.microsof t.com...[color=blue]
                  > Jon Davis <jon@REMOVE.ME. PLEASE.jondavis .net> wrote:[color=green]
                  > > "Jon Skeet" <skeet@pobox.co m> wrote in message
                  > > news:MPG.19845e 59d982c86598a17 1@news.microsof t.com...[color=darkred]
                  > > > Have you tried running the code in release mode? Maybe it's just a
                  > > > debugger bug.[/color]
                  > >
                  > > Ah, a helpful, insightful answer that doesn't involve your copy-pasting[/color][/color]
                  into[color=blue][color=green]
                  > > the debugger (which I can do)!
                  > >
                  > > Actually, this answer made me realize that files were not being properly
                  > > propogated to the proper directories upon compile. Hopefully that's my
                  > > problem, still testing ...
                  > >
                  > > (As I said, there was no more source code to demonstrate my problem. ;)[/color]
                  >
                  > But there was - if you'd posted a short but complete example which
                  > *wasn't* working on your box,[/color]

                  But see I couldn't do that without giving you everything. I have ten
                  projects all outputting to the same directory, and I didn't realize that
                  this was the problem.

                  There was absolutely no way to help you help me by reproducing sample code
                  in new project code because I wouldn't have repeated the same error (unless
                  per chance I actually caught myself along the way).

                  Thanks again for your insightful question (re your previous post, "Release
                  mode"), it actually really helped me drill down to the problem, and frankly
                  I don't know how else I would have found my error.

                  Jon


                  Comment

                  • Jon Skeet

                    #10
                    Re: Problem with virtual method

                    Jon Davis <jon@REMOVE.ME. PLEASE.jondavis .net> wrote:[color=blue][color=green]
                    > > But there was - if you'd posted a short but complete example which
                    > > *wasn't* working on your box,[/color]
                    >
                    > But see I couldn't do that without giving you everything.[/color]

                    But you could. You could have reduced the code gradually (a copy of the
                    code, rather) until it worked. That would actually have shown you the
                    error very quickly (see below) due to what the problem turned out to
                    be. If the problem *had* been in the code, however, you would then have
                    found it when it went from "not working" to "working". Either way,
                    you'd have found the problem in the end.
                    [color=blue]
                    > There was absolutely no way to help you help me by reproducing sample code
                    > in new project code because I wouldn't have repeated the same error (unless
                    > per chance I actually caught myself along the way).[/color]

                    Which you should have done, because immediately after copying the full
                    code, the first thing to do would be to test that it still didn't work.
                    [color=blue]
                    > Thanks again for your insightful question (re your previous post, "Release
                    > mode"), it actually really helped me drill down to the problem, and frankly
                    > I don't know how else I would have found my error.[/color]

                    See above.

                    --
                    Jon Skeet - <skeet@pobox.co m>
                    Pobox has been discontinued as a separate service, and all existing customers moved to the Fastmail platform.

                    If replying to the group, please do not mail me too

                    Comment

                    • Jon Davis

                      #11
                      Re: Problem with virtual method


                      "Jon Davis" <jon@REMOVE.ME. PLEASE.jondavis .net> wrote in message
                      news:untl3npTDH A.2004@TK2MSFTN GP11.phx.gbl...[color=blue]
                      > "Jon Skeet" <skeet@pobox.co m> wrote in message
                      > news:MPG.19845e 59d982c86598a17 1@news.microsof t.com...[color=green]
                      > > Have you tried running the code in release mode? Maybe it's just a
                      > > debugger bug.[/color]
                      >
                      > Ah, a helpful, insightful answer that doesn't involve your copy-pasting[/color]
                      into[color=blue]
                      > the debugger (which I can do)!
                      >
                      > Actually, this answer made me realize that files were not being properly
                      > propogated to the proper directories upon compile. Hopefully that's my
                      > problem, still testing ...[/color]

                      Hmm, nope, this wasn't the problem. The problem remains.

                      ... Time to find other resources ..



                      Comment

                      • Jon Davis

                        #12
                        Re: Problem with virtual method

                        Jon, it took me about half an hour to hand-pick the relevant lines of code
                        that would be useful to you. You are insistent on not visually evaluating
                        what I wrote, which is your prerogative.

                        Developing sample code that reproduces the problem is only possible if you
                        know how to reproduce the problem, and I don't know how to reproduce the
                        problem. Obviously if someone in this group cannot help me drill down to the
                        problem with the information I provided and without a full reproduction,
                        then, in order to provide a reproduction of the problem, I will have to
                        rewrite from the ground up, adding line by line what I've done, until I
                        discover the culprit (hence, I find what makes it reproduceable). But that
                        will take days, and by the time I find the culprit I won't need this
                        newsgroup.

                        Thanks anyway.

                        Jon


                        "Jon Skeet" <skeet@pobox.co m> wrote in message
                        news:MPG.19846a abd596cfca98a17 6@news.microsof t.com...[color=blue]
                        > Jon Davis <jon@REMOVE.ME. PLEASE.jondavis .net> wrote:[color=green][color=darkred]
                        > > > But there was - if you'd posted a short but complete example which
                        > > > *wasn't* working on your box,[/color]
                        > >
                        > > But see I couldn't do that without giving you everything.[/color]
                        >
                        > But you could. You could have reduced the code gradually (a copy of the
                        > code, rather) until it worked. That would actually have shown you the
                        > error very quickly (see below) due to what the problem turned out to
                        > be. If the problem *had* been in the code, however, you would then have
                        > found it when it went from "not working" to "working". Either way,
                        > you'd have found the problem in the end.
                        >[color=green]
                        > > There was absolutely no way to help you help me by reproducing sample[/color][/color]
                        code[color=blue][color=green]
                        > > in new project code because I wouldn't have repeated the same error[/color][/color]
                        (unless[color=blue][color=green]
                        > > per chance I actually caught myself along the way).[/color]
                        >
                        > Which you should have done, because immediately after copying the full
                        > code, the first thing to do would be to test that it still didn't work.
                        >[color=green]
                        > > Thanks again for your insightful question (re your previous post,[/color][/color]
                        "Release[color=blue][color=green]
                        > > mode"), it actually really helped me drill down to the problem, and[/color][/color]
                        frankly[color=blue][color=green]
                        > > I don't know how else I would have found my error.[/color]
                        >
                        > See above.
                        >
                        > --
                        > Jon Skeet - <skeet@pobox.co m>
                        > http://www.pobox.com/~skeet/
                        > If replying to the group, please do not mail me too[/color]


                        Comment

                        • Jon Davis

                          #13
                          Re: Problem with virtual method

                          I should point out that my project is not currently open source and as such
                          it is private. I am not going to post the entire project nor link to it, it
                          would be a waste of your time anyway (Mr. Skeet).

                          I should also point out that I cannot simply remove code until the problem
                          fixes itself.

                          1. I don't know what to delete.
                          2. If I do delete anything, it will break the entire project.
                          3. I cannot simply paste the code into a new project because there are far
                          too many interdependent classes and types and methods, etc.

                          Finally, I should point out that, while we must try to be respectful to
                          those who help, those who help should be respectful of these (above)
                          hindrances. I've done the best I can to provide what I know without posting
                          a link to the entire solution in a .zip file, short of rewriting code from
                          scratch on this matter, which, as I said, will negate the usefulness of this
                          group.

                          Seems I have no choice, which is fine. Nobody owes me anything.

                          Thanks again for the willingness to try to help. Please put your tired self
                          to rest.

                          Jon


                          "Jon Davis" <jon@REMOVE.ME. PLEASE.jondavis .net> wrote in message
                          news:umljc%23pT DHA.3796@tk2msf tngp13.phx.gbl. ..[color=blue]
                          > Jon, it took me about half an hour to hand-pick the relevant lines of code
                          > that would be useful to you. You are insistent on not visually evaluating
                          > what I wrote, which is your prerogative.
                          >
                          > Developing sample code that reproduces the problem is only possible if you
                          > know how to reproduce the problem, and I don't know how to reproduce the
                          > problem. Obviously if someone in this group cannot help me drill down to[/color]
                          the[color=blue]
                          > problem with the information I provided and without a full reproduction,
                          > then, in order to provide a reproduction of the problem, I will have to
                          > rewrite from the ground up, adding line by line what I've done, until I
                          > discover the culprit (hence, I find what makes it reproduceable). But that
                          > will take days, and by the time I find the culprit I won't need this
                          > newsgroup.
                          >
                          > Thanks anyway.
                          >
                          > Jon
                          >
                          >
                          > "Jon Skeet" <skeet@pobox.co m> wrote in message
                          > news:MPG.19846a abd596cfca98a17 6@news.microsof t.com...[color=green]
                          > > Jon Davis <jon@REMOVE.ME. PLEASE.jondavis .net> wrote:[color=darkred]
                          > > > > But there was - if you'd posted a short but complete example which
                          > > > > *wasn't* working on your box,
                          > > >
                          > > > But see I couldn't do that without giving you everything.[/color]
                          > >
                          > > But you could. You could have reduced the code gradually (a copy of the
                          > > code, rather) until it worked. That would actually have shown you the
                          > > error very quickly (see below) due to what the problem turned out to
                          > > be. If the problem *had* been in the code, however, you would then have
                          > > found it when it went from "not working" to "working". Either way,
                          > > you'd have found the problem in the end.
                          > >[color=darkred]
                          > > > There was absolutely no way to help you help me by reproducing sample[/color][/color]
                          > code[color=green][color=darkred]
                          > > > in new project code because I wouldn't have repeated the same error[/color][/color]
                          > (unless[color=green][color=darkred]
                          > > > per chance I actually caught myself along the way).[/color]
                          > >
                          > > Which you should have done, because immediately after copying the full
                          > > code, the first thing to do would be to test that it still didn't work.
                          > >[color=darkred]
                          > > > Thanks again for your insightful question (re your previous post,[/color][/color]
                          > "Release[color=green][color=darkred]
                          > > > mode"), it actually really helped me drill down to the problem, and[/color][/color]
                          > frankly[color=green][color=darkred]
                          > > > I don't know how else I would have found my error.[/color]
                          > >
                          > > See above.
                          > >
                          > > --
                          > > Jon Skeet - <skeet@pobox.co m>
                          > > http://www.pobox.com/~skeet/
                          > > If replying to the group, please do not mail me too[/color]
                          >
                          >[/color]


                          Comment

                          • Jay B. Harlow [MVP - Outlook]

                            #14
                            Re: Problem with virtual method

                            Jon,
                            Go the other direction!

                            Start a new solution with two projects. The first project loads the second
                            project and calls the virtual method. Include the minimalist amount of code
                            to demonstrate the feature. Does it work?

                            Start adding features from your larger project, until this new project
                            fails. Baby steps! Add things one at a time. Hopefully when you added X, it
                            fails, then you know to look at X in the larger project.

                            This helps solves two problems.
                            1. It gives you a reference point to compare to the larger project.
                            2. It proves what you are attempting to do works, or doesn't work. Without
                            being bothered by the shear volume of the rest of your main project.

                            3. It also provides a small project that fails, which is what Jon Skeet was
                            asking for.

                            Hope this helps
                            Jay

                            "Jon Davis" <jon@REMOVE.ME. PLEASE.jondavis .net> wrote in message
                            news:OtFKSHqTDH A.3192@tk2msftn gp13.phx.gbl...[color=blue]
                            > I should point out that my project is not currently open source and as[/color]
                            such[color=blue]
                            > it is private. I am not going to post the entire project nor link to it,[/color]
                            it[color=blue]
                            > would be a waste of your time anyway (Mr. Skeet).
                            >
                            > I should also point out that I cannot simply remove code until the problem
                            > fixes itself.
                            >
                            > 1. I don't know what to delete.
                            > 2. If I do delete anything, it will break the entire project.
                            > 3. I cannot simply paste the code into a new project because there are[/color]
                            far[color=blue]
                            > too many interdependent classes and types and methods, etc.
                            >
                            > Finally, I should point out that, while we must try to be respectful to
                            > those who help, those who help should be respectful of these (above)
                            > hindrances. I've done the best I can to provide what I know without[/color]
                            posting[color=blue]
                            > a link to the entire solution in a .zip file, short of rewriting code from
                            > scratch on this matter, which, as I said, will negate the usefulness of[/color]
                            this[color=blue]
                            > group.
                            >
                            > Seems I have no choice, which is fine. Nobody owes me anything.
                            >
                            > Thanks again for the willingness to try to help. Please put your tired[/color]
                            self[color=blue]
                            > to rest.
                            >
                            > Jon
                            >
                            >
                            > "Jon Davis" <jon@REMOVE.ME. PLEASE.jondavis .net> wrote in message
                            > news:umljc%23pT DHA.3796@tk2msf tngp13.phx.gbl. ..[color=green]
                            > > Jon, it took me about half an hour to hand-pick the relevant lines of[/color][/color]
                            code[color=blue][color=green]
                            > > that would be useful to you. You are insistent on not visually[/color][/color]
                            evaluating[color=blue][color=green]
                            > > what I wrote, which is your prerogative.
                            > >
                            > > Developing sample code that reproduces the problem is only possible if[/color][/color]
                            you[color=blue][color=green]
                            > > know how to reproduce the problem, and I don't know how to reproduce the
                            > > problem. Obviously if someone in this group cannot help me drill down to[/color]
                            > the[color=green]
                            > > problem with the information I provided and without a full reproduction,
                            > > then, in order to provide a reproduction of the problem, I will have to
                            > > rewrite from the ground up, adding line by line what I've done, until I
                            > > discover the culprit (hence, I find what makes it reproduceable). But[/color][/color]
                            that[color=blue][color=green]
                            > > will take days, and by the time I find the culprit I won't need this
                            > > newsgroup.
                            > >
                            > > Thanks anyway.
                            > >
                            > > Jon
                            > >
                            > >
                            > > "Jon Skeet" <skeet@pobox.co m> wrote in message
                            > > news:MPG.19846a abd596cfca98a17 6@news.microsof t.com...[color=darkred]
                            > > > Jon Davis <jon@REMOVE.ME. PLEASE.jondavis .net> wrote:
                            > > > > > But there was - if you'd posted a short but complete example which
                            > > > > > *wasn't* working on your box,
                            > > > >
                            > > > > But see I couldn't do that without giving you everything.
                            > > >
                            > > > But you could. You could have reduced the code gradually (a copy of[/color][/color][/color]
                            the[color=blue][color=green][color=darkred]
                            > > > code, rather) until it worked. That would actually have shown you the
                            > > > error very quickly (see below) due to what the problem turned out to
                            > > > be. If the problem *had* been in the code, however, you would then[/color][/color][/color]
                            have[color=blue][color=green][color=darkred]
                            > > > found it when it went from "not working" to "working". Either way,
                            > > > you'd have found the problem in the end.
                            > > >
                            > > > > There was absolutely no way to help you help me by reproducing[/color][/color][/color]
                            sample[color=blue][color=green]
                            > > code[color=darkred]
                            > > > > in new project code because I wouldn't have repeated the same error[/color]
                            > > (unless[color=darkred]
                            > > > > per chance I actually caught myself along the way).
                            > > >
                            > > > Which you should have done, because immediately after copying the full
                            > > > code, the first thing to do would be to test that it still didn't[/color][/color][/color]
                            work.[color=blue][color=green][color=darkred]
                            > > >
                            > > > > Thanks again for your insightful question (re your previous post,[/color]
                            > > "Release[color=darkred]
                            > > > > mode"), it actually really helped me drill down to the problem, and[/color]
                            > > frankly[color=darkred]
                            > > > > I don't know how else I would have found my error.
                            > > >
                            > > > See above.
                            > > >
                            > > > --
                            > > > Jon Skeet - <skeet@pobox.co m>
                            > > > http://www.pobox.com/~skeet/
                            > > > If replying to the group, please do not mail me too[/color]
                            > >
                            > >[/color]
                            >
                            >[/color]


                            Comment

                            • Jon Davis

                              #15
                              Re: Problem with virtual method

                              Thanks for the feedback, Jay, I'll consider your advice. And thanks for not
                              beating me over the head like some other people have done in the past for
                              not doing things their way.

                              Jon


                              "Jay B. Harlow [MVP - Outlook]" <Jay_Harlow@ema il.msn.com> wrote in message
                              news:ughBIWtTDH A.560@TK2MSFTNG P10.phx.gbl...[color=blue]
                              > Jon,
                              > Go the other direction!
                              >
                              > Start a new solution with two projects. The first project loads the second
                              > project and calls the virtual method. Include the minimalist amount of[/color]
                              code[color=blue]
                              > to demonstrate the feature. Does it work?
                              >
                              > Start adding features from your larger project, until this new project
                              > fails. Baby steps! Add things one at a time. Hopefully when you added X,[/color]
                              it[color=blue]
                              > fails, then you know to look at X in the larger project.
                              >
                              > This helps solves two problems.
                              > 1. It gives you a reference point to compare to the larger project.
                              > 2. It proves what you are attempting to do works, or doesn't work. Without
                              > being bothered by the shear volume of the rest of your main project.
                              >
                              > 3. It also provides a small project that fails, which is what Jon Skeet[/color]
                              was[color=blue]
                              > asking for.
                              >
                              > Hope this helps
                              > Jay
                              >
                              > "Jon Davis" <jon@REMOVE.ME. PLEASE.jondavis .net> wrote in message
                              > news:OtFKSHqTDH A.3192@tk2msftn gp13.phx.gbl...[color=green]
                              > > I should point out that my project is not currently open source and as[/color]
                              > such[color=green]
                              > > it is private. I am not going to post the entire project nor link to it,[/color]
                              > it[color=green]
                              > > would be a waste of your time anyway (Mr. Skeet).
                              > >
                              > > I should also point out that I cannot simply remove code until the[/color][/color]
                              problem[color=blue][color=green]
                              > > fixes itself.
                              > >
                              > > 1. I don't know what to delete.
                              > > 2. If I do delete anything, it will break the entire project.
                              > > 3. I cannot simply paste the code into a new project because there are[/color]
                              > far[color=green]
                              > > too many interdependent classes and types and methods, etc.
                              > >
                              > > Finally, I should point out that, while we must try to be respectful to
                              > > those who help, those who help should be respectful of these (above)
                              > > hindrances. I've done the best I can to provide what I know without[/color]
                              > posting[color=green]
                              > > a link to the entire solution in a .zip file, short of rewriting code[/color][/color]
                              from[color=blue][color=green]
                              > > scratch on this matter, which, as I said, will negate the usefulness of[/color]
                              > this[color=green]
                              > > group.
                              > >
                              > > Seems I have no choice, which is fine. Nobody owes me anything.
                              > >
                              > > Thanks again for the willingness to try to help. Please put your tired[/color]
                              > self[color=green]
                              > > to rest.
                              > >
                              > > Jon
                              > >
                              > >
                              > > "Jon Davis" <jon@REMOVE.ME. PLEASE.jondavis .net> wrote in message
                              > > news:umljc%23pT DHA.3796@tk2msf tngp13.phx.gbl. ..[color=darkred]
                              > > > Jon, it took me about half an hour to hand-pick the relevant lines of[/color][/color]
                              > code[color=green][color=darkred]
                              > > > that would be useful to you. You are insistent on not visually[/color][/color]
                              > evaluating[color=green][color=darkred]
                              > > > what I wrote, which is your prerogative.
                              > > >
                              > > > Developing sample code that reproduces the problem is only possible if[/color][/color]
                              > you[color=green][color=darkred]
                              > > > know how to reproduce the problem, and I don't know how to reproduce[/color][/color][/color]
                              the[color=blue][color=green][color=darkred]
                              > > > problem. Obviously if someone in this group cannot help me drill down[/color][/color][/color]
                              to[color=blue][color=green]
                              > > the[color=darkred]
                              > > > problem with the information I provided and without a full[/color][/color][/color]
                              reproduction,[color=blue][color=green][color=darkred]
                              > > > then, in order to provide a reproduction of the problem, I will have[/color][/color][/color]
                              to[color=blue][color=green][color=darkred]
                              > > > rewrite from the ground up, adding line by line what I've done, until[/color][/color][/color]
                              I[color=blue][color=green][color=darkred]
                              > > > discover the culprit (hence, I find what makes it reproduceable). But[/color][/color]
                              > that[color=green][color=darkred]
                              > > > will take days, and by the time I find the culprit I won't need this
                              > > > newsgroup.
                              > > >
                              > > > Thanks anyway.
                              > > >
                              > > > Jon
                              > > >
                              > > >
                              > > > "Jon Skeet" <skeet@pobox.co m> wrote in message
                              > > > news:MPG.19846a abd596cfca98a17 6@news.microsof t.com...
                              > > > > Jon Davis <jon@REMOVE.ME. PLEASE.jondavis .net> wrote:
                              > > > > > > But there was - if you'd posted a short but complete example[/color][/color][/color]
                              which[color=blue][color=green][color=darkred]
                              > > > > > > *wasn't* working on your box,
                              > > > > >
                              > > > > > But see I couldn't do that without giving you everything.
                              > > > >
                              > > > > But you could. You could have reduced the code gradually (a copy of[/color][/color]
                              > the[color=green][color=darkred]
                              > > > > code, rather) until it worked. That would actually have shown you[/color][/color][/color]
                              the[color=blue][color=green][color=darkred]
                              > > > > error very quickly (see below) due to what the problem turned out to
                              > > > > be. If the problem *had* been in the code, however, you would then[/color][/color]
                              > have[color=green][color=darkred]
                              > > > > found it when it went from "not working" to "working". Either way,
                              > > > > you'd have found the problem in the end.
                              > > > >
                              > > > > > There was absolutely no way to help you help me by reproducing[/color][/color]
                              > sample[color=green][color=darkred]
                              > > > code
                              > > > > > in new project code because I wouldn't have repeated the same[/color][/color][/color]
                              error[color=blue][color=green][color=darkred]
                              > > > (unless
                              > > > > > per chance I actually caught myself along the way).
                              > > > >
                              > > > > Which you should have done, because immediately after copying the[/color][/color][/color]
                              full[color=blue][color=green][color=darkred]
                              > > > > code, the first thing to do would be to test that it still didn't[/color][/color]
                              > work.[color=green][color=darkred]
                              > > > >
                              > > > > > Thanks again for your insightful question (re your previous post,
                              > > > "Release
                              > > > > > mode"), it actually really helped me drill down to the problem,[/color][/color][/color]
                              and[color=blue][color=green][color=darkred]
                              > > > frankly
                              > > > > > I don't know how else I would have found my error.
                              > > > >
                              > > > > See above.
                              > > > >
                              > > > > --
                              > > > > Jon Skeet - <skeet@pobox.co m>
                              > > > > http://www.pobox.com/~skeet/
                              > > > > If replying to the group, please do not mail me too
                              > > >
                              > > >[/color]
                              > >
                              > >[/color]
                              >
                              >[/color]


                              Comment

                              Working...