0

I just need another pair of eyes... I don't see anything wrong with the following. In fact, I swear I had something just like this not long ago, and it worked.

In my Collections.dll:

namespace Collections
{
   public class CSuperAutoPool
   {
      public static CSuperAutoPool ActivateByType(Type typeToBeActivated, params object[] activatedArguments)
      {
          //...
      }
   }
}

In another DLL, I have referenced the collections DLL project, and use it in this function:

namespace Organization
{
    public class CBaseEntity : CSuperAutoPool
    {
        protected static CBaseEntity Create()
        {
            //...
            CBaseEntity created = (CBaseEntity)CSuperAutoPool.ActivateByType(callingType); //Error here.
            //...
        }
    }
}

Error: 'Collections.CSuperAutoPool' does not contain a definition for 'ActivateByType'

I have used ActivateByType, within CSuperAutoPool, in a different function, and that one does not have errors. The Collections DLL compiles without errors. In the same DLL where the Organization namespace exists, have used various other aspects of the CSuperAutoPool class in other ways, without compiler errors.

JnZ
  • 1
  • 1
  • It looks like you declare the function with two parameters and then call it with one. I see you have the `params` there as optional arguments, but I'm not sure - do you have to pass `null` if you don't want any additional arguments (I don't use that feature very often)? – FrustratedWithFormsDesigner Aug 04 '10 at 17:40
  • @FrustratedWithFormsDesigner: No, you don't need to pass null. – Dirk Vollmar Aug 04 '10 at 17:41
  • 1
    @FrustratedWithFormsDesigner - when a parameter is marked as `params` it is fine to omit it when calling the method. – Greg Aug 04 '10 at 17:43
  • @0xA3: alright then, I'm stumped too! – FrustratedWithFormsDesigner Aug 04 '10 at 17:44
  • 1
    Have you tried doing 'Clean Solution' in Visual Studio, then rebuilding? That sometimes sorts out any funny behaviour... – robyaw Aug 04 '10 at 17:47
  • What type is `callingtype`? Or, failing that, do you have a `using` statement for `Collections`? (Incidentally, Collections is a terrible name for a namespace) – Mike Caron Aug 04 '10 at 17:57

2 Answers2

3

There must be something missing from your example, or you are not using the version of the code that you think you are using, e.g. could it be that there is another class called CSuperAutoPool in your project, possibly in a referenced assembly?

The following snippets compiles without errors:

namespace Collections
{
    public class CSuperAutoPool
    {
        public static CSuperAutoPool ActivateByType(
            Type typeToBeActivated, params object[] activatedArguments)
        {
            //...
            return null;
        }
    }
}

namespace Organization
{
    using Collections;
    public class CBaseEntity : CSuperAutoPool
    {
        protected static CBaseEntity Create()
        {
            Type callingType = null;
            //...
            CBaseEntity created = 
                (CBaseEntity)CSuperAutoPool.ActivateByType(callingType); 
            //...
            return created;
        }
    }
}
Dirk Vollmar
  • 172,527
  • 53
  • 255
  • 316
0

Found it! 0xA3 gave me the hint I needed with: "you are not using the version of the code that you think you are using"

When I added the Collections reference to the Organization project, it did not checkmark the Collections project to compile in the Configurations Manager. In other words, my Collections DLL was not compiling unless I did it by hand.

Thank you, that's what I meant by an extra set of eyes. :-)

JnZ
  • 1
  • 1