none
"Could not load type" error?

    Question

  • I'm trying to create the configuration page for a custom Information Management Policy, based on the Watermark policy example in chapter 8 of the Inside MOSS 2007 Microsoft Press book.  The policy itself (i.e. without edit page) seems to work okay, but whenever I try to access the Policy Edit page for, say, a content type, I get an error in SharePoint: "Could not load type 'PolicyTest.Watermark.WatermarkPolicySettings'".  The namespace and class names are correct (the namespace is PolicyTest.Watermark, and the class WatermarkPolicySettings). 

    I have copied the ascx to the \12\TEMPLATE\LAYOUTS directory, and the DLL containing the code-behind is in the GAC (and is otherwise working: all of the activation / registration code is in the same assembly).  I haven't included any paths to the ascx in the RootFiles or TemplateFiles section of the WSP's manifest, mainly because I was getting an error there too. 

    I have tried searching and comparing my code to various online examples, but can't find any hints as to why SharePoint can't see the class.  Any help would be greatly appreciated: SharePoint is very frustrating, sometimes.  :)

    By the way, I am using Visual Studio 2005 with VSEWSS 1.1, and MOSS 2007. 

    --
    Rebecca
    Tuesday, August 12, 2008 8:45 PM

Answers

All replies

  • Have you made sure that WatermarkPolicySettings is declared publically?

    namespace PolicyTest.Watermark
    {
       public class WatermarkPolicySettings
      {
      }
    }
    Olly
    Wednesday, August 13, 2008 8:17 AM
  • Yes, it is public.  However, it is a partial class (the rest is in the designer.cs).  Would that make a difference? 
    Wednesday, August 13, 2008 12:50 PM
  • I've been playing with this some more, but still haven't been able to get anything working.  Can anyone tell me whether it is a problem that the code-behind for the ascx is in the same assembly as the rest of the policy / activation code?  Or whether it needs to be deployed to anywhere other than in the GAC?  Also, does it make any difference that the code-behind is split into 2 files, the cs and the designer.cs? 

    Any help or suggestions are still greatly appreciated.  I am completely at a loss as to what to try next. 
    Wednesday, August 13, 2008 6:16 PM
  • check this thread where i mentioned details also.

    http://forums.msdn.microsoft.com/en-US/sharepointdevelopment/thread/e97e7f5b-a3a6-441f-b71e-6ee7232e9423

    in your case you need to put your ASCX file in CONTROLTEMPLATE folder which exist under TEMPLATE folder like TEMPLATE\CONTROLTEMPLATE.
     
    secondly put your dll to GAC but in your ASCX file put the details about your class and assembly as i mentioned in above thread inside inherit statement declaration on ASCS file.

    Once you do above, ASP.net will be able to find your class in your assembly.
    • Marked as answer by rmthornton Thursday, August 14, 2008 1:16 PM
    Wednesday, August 13, 2008 7:12 PM
  • In my case I was able to resolve this by copying the dll in the web bin directory.

    Tuesday, November 06, 2012 7:09 PM