+1-888-365-2779
Try Now
More in this section
Categories
Bloggers
Blogs RSS feed

A forgotten post : Registring a Custom Module with Sitefinity

by Ivan Osmak

Custom module 101 Over the last week or so I’ve received several comments asking how to register a custom module in Sitefinity. Obviously, this post should have been written way before in the Building a pluggable module section, but I have somehow missed it. I apologize and would like to thank the kind readers that pointed that out.

So here it goes… registring the module with Sitefinty. In case you have not already downloaded the latest download of Contacts Module project, you can do it here . The zip file contains two projects : Sample.Contacts and Sample.Contacts.Data.

You need to add both of those projects to your existing project in Visual Studio in effect creating a solution. If you already have a solution, just add those two projects. Then add both projects as a reference to the WebSite project (Sitefinity website).

Now that you have that project, let’s see what we need to do to register it.

1. You should add the config section for contacts module to your web.config. So find in your web.config <configSections> element, and then inside if <sectionGroup name=”telerik”> element. Paste the underline line inside that element.

<configSections>
<sectionGroup name =“telerik>
<section name =“contacts“
type =“Sample.Contacts.Configuration.SectionHandler, Sample.Contacts“
requirePermission =“false“/>
</sectionGroup>
</configSections>

Sample.Contacts is the name of the project. SectionHandler is the class inheriting the base class ConfigurationSection and contains the functionality for loading and accessing the contacts section information.

2. Add the contacts section inside of telerik section group.Your contacts section will allow you to set various settings required by Contacts module. So find the <telerik> element and past the underlined text somewhere inside it (be careful <telerik> element must be a immediate parent of <contacts> section here).

<telerik>
<contacts defaultProvider =“Sitefinity“>
<providers>
<clear/>
<add name =“Sitefinity“ securityProviderName =“”
type =“Sample.Contacts.Data.DefaultProvider, Sample.Contacts.Data“
connectionStringName =“DefaultConnection“ visible =“true“ />
</providers>
</contacts>
</telerik>

As you can see the first and most rudimentary setting we need to set is the provider for this module. Sample.Contacts.Data is the data project for the Contacts module and DefaultProvider is the class providing an implementation for the provider model.

3. Finally, you have to register the module. The previous two steps were needed by the module, this last step actually registers the module with Sitefinity. Find the <framework> element and then <modules> element inside of it. Paste the underlined line inside of <module> element.

<framework>
<modules>
<add type =“Sample.Contacts.ContactsModule, Sample.Contacts“/>
</modules>
</framework>

ContactsModule is the class, providing substantial information for your custom module. In my previous posts I’ve referred to this class as the main module class also. That’s the one inheriting WebModule class.

That’s all. Let me know if you need any other assistance.

21 comments

Leave a comment
  1. anesta Jun 26, 2007
    This is my problem: XML Parsing Error: mismatched tag. Expected: . Location: http://localhost/telerik/Sitefinity2.5/Default.aspx Line Number 56, Column 6: ————————–^ HELP PLEASE
  2. Jeff Jun 26, 2007
    The Conclusion: Do not copy-paste from a blog post in which the wrong quotes have been used. anesta, replace all the quotes from Ivan’s post with the “regular” quotes. i.e. - ” Ivan, great posts! Keep’em coming!
  3. Sean Molam Jun 26, 2007
    Hi Ivan Thanks for the great tips!! But you spelt Registering wrong in the title of the post :) Sean
  4. chris Jul 04, 2007
    I just added your suggestions to my project, and I'm getting the following error. Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "Telerik.Resources.Messages.resources" was correctly embedded or linked into assembly "Telerik.Framework" at compile time, or that all the satellite assemblies required are loadable and fully signed. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Resources.MissingManifestResourceException: Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "Telerik.Resources.Messages.resources" was correctly embedded or linked into assembly "Telerik.Framework" at compile time, or that all the satellite assemblies required are loadable and fully signed. Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. Stack Trace: [MissingManifestResourceException: Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "Telerik.Resources.Messages.resources" was correctly embedded or linked into assembly "Telerik.Framework" at compile time, or that all the satellite assemblies required are loadable and fully signed.] System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo culture, Boolean createIfNotExists, Boolean tryParents) +655 System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo culture, Boolean createIfNotExists, Boolean tryParents) +681 System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo culture, Boolean createIfNotExists, Boolean tryParents) +681 System.Resources.ResourceManager.GetString(String name, CultureInfo culture) +77 Telerik.ModuleManager.LoadModules(Boolean reload) +398 Telerik.ModuleManager.LoadModules() +25 Telerik.ModuleManager..cctor() +96 [TypeInitializationException: The type initializer for 'Telerik.ModuleManager' threw an exception.] Telerik.ModuleManager.LoadModules(Boolean reload) +0 Telerik.Cms.Web.CmsHttpModule..cctor() +38 [TypeInitializationException: The type initializer for 'Telerik.Cms.Web.CmsHttpModule' threw an exception.] [TargetInvocationException: Exception has been thrown by the target of an invocation.] System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandle& ctor, Boolean& bNeedSecurityCheck) +0 System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean fillCache) +103 System.RuntimeType.CreateInstanceImpl(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean fillCache) +261 System.Activator.CreateInstance(Type type, Boolean nonPublic) +66 System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) +1036 System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) +114 System.Web.Configuration.ModulesEntry.Create() +41 System.Web.Configuration.HttpModulesSection.CreateModules() +203 System.Web.HttpApplication.InitModules() +219 System.Web.HttpApplication.InitInternal(HttpContext context, HttpApplicationState state, MethodInfo[] handlers) +1251 System.Web.HttpApplicationFactory.GetNormalApplicationInstance(HttpContext context) +243 System.Web.HttpApplicationFactory.GetApplicationInstance(HttpContext context) +106 System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr) +317 Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.210 Any ideas to help? Thanks!
  5. Seth Cleaver Jul 09, 2007
    I thought these posts were going to be regular but they seem to have stopped almost a month ago and moldule project ain't event finished! I have been finding them very helpful though.
  6. Seth Jul 09, 2007
    My apologises the module project is finished - still you did say the posts were going to be regular :-)
  7. Ivan Jul 09, 2007
    Hi Seth, I would like to apologize for the big empty gap in posting... and I won't even try to make excuses. From today on, blogging will be more regular. Once again, I'd like to apologize to everyone who I let down.
  8. Grant Jul 09, 2007
    Ivan, I just wanted to say thanks for this blog. The contacts module was a perfect complement to the recently released Dev manual. I do have a request though...Could you do a couple of posts extending the Contacts module to use versioning and workflow?
  9. Ivan Jul 09, 2007
    Hi Grant, will do! Thanks for the encouragement. I will try to write about workflow this week and then versioning the next week. I'd really like to be able to respond sooner, but things are really hectic at the moment... Also, I'd like to thank you for the feedback. There is perhaps nothing better to say to a blogger, than to suggest a topic for a post :)
  10. Meat Wheels Jul 18, 2007
    Great blog, thanks. I'll be visiting back very often!
  11. Ivan Jul 23, 2007
    Hi Chris, sorry for the extremely late response. I've had your problem on todo list... but I've been really swamped with tasks. So here is the reason for your problem and then I'll provide you with the solution. PROBLEM : I've managed to reproduce the problem by simply copying .dll files to a bin folder of a website and then registering the module in web.config. Namely, since contacts module references Sitefinity assemblies (such as Telerik.Framework, Telerik.Cms.Web.UI, etc) it is necessary that those referenced files are of the same version as the one of your web site. So, since I have referenced files on my machine, you can't just add .dll files and that's where the problem is. SOLUTION : Add the Sample.Contacts and Sample.Contacts.Data projects to your web site and in effect create a solution. Delete the Sample.Contacts.dll and Sample.Contacts.Data.dll from your bin folder if they are still there. Add these two projects as references to your web site. Lastly, open the references for both projects and reference your dlls. So, in Sample.Contacts you need to replace the references of Telerik.Cms.Web.UI, Telerik.Framework and Telerik.Security with the references to those assemblies in your bin folder. Same thing you need to do for Sample.Contacts.Data : replace Nolics.Engine.v4.2, Telerik.DataAccess, Telerik.Framework. Once again, I apologize for the late response. Regards, Ivan
  12. tito Aug 06, 2007
    hi. this is my exception A required control was not found in the template for "Sample.Contacts.WebControls.Admin.ContactEditor+ContactEditorContainer". The control must be assignable form type "System.Web.UI.Control" and must have ID "cancel". need help plz.
  13. tito Aug 06, 2007
    hi. this is my exception A required control was not found in the template for "Sample.Contacts.WebControls.Admin.ContactEditor+ContactEditorContainer". The control must be assignable form type "System.Web.UI.Control" and must have ID "cancel". need help plz.
  14. Ivan Aug 06, 2007
    Hi Tito, this means that you are missing the control with id "cancel" in your template. Make sure you have a link or a button in your template that has id "cancel". Tomorrow I will write a post on using a GenericContainer class. Thanks, Ivan
  15. jason Aug 07, 2007
    Hi Ivan, I have followed the instructions and had the same problem as Chris above. I managed to resolve that by following your post on 7/23 and now it builds and the module shows up... but now I'm getting the same error as tito above. I'm sorry, but I don't follow your instructions to him about adding a link or button to a template. I understand to add a button with the name "cancel" but on what template? Do I need to create this template from scratch or does it exist somewhere? Thanks a lot for your help
  16. jason Aug 07, 2007
    Ivan, I think I've got it mostly figured out. There is a "// TODO : implement default template" in DefaultContactEditorTemplate.InstatiateIn on ContactEditor.cs. What exactly is supposed to be there? Thanks
  17. jason Aug 07, 2007
    Ivan, I think I've got it mostly figured out. There is a "// TODO : implement default template" in DefaultContactEditorTemplate.InstatiateIn on ContactEditor.cs. What exactly is supposed to be there? Thanks
  18. Ivan Aug 07, 2007
    Hi Jason, the Default Template classes are used for the cases when Page object is not available (so Page.LoadTemplate method can't be used). This is the case for example when you are working with the control in VS designer. So what you should do in Default template is recreate the .ascx template in code by creating controls and adding them to the container (parameter of InstatiateIn method). Obviously, you don't really have to do this (it can be painful if you are dealing with a complex control :), but it will make your controls more robust and useful. The first choice when creating a control is to consider creating an .ascx template and loading it with Page.LoadTemplate method into the container. Take a look at the CreateChildControls method and see the logic that creates a template for the control. The default template class is like a plan B. I hope this clears it a bit. Regards, Ivan
  19. Pat O. Sep 07, 2007
    Jason, I'm trying to code the DefaultContactEditorTemplate as you have outlined but I'm having a few problems. It would be really a big help if you could provide the specific code for the Contacts example. This speed bump is keeping me from taking advantage of your great work on the Contacts example. It's alot easier for me to understand the whole concept better if I can get it running. Thanks, Pat O.
  20. Darchele Webb Oct 01, 2007
    I am at the same point as the above posts (Pat O, Jason and Tito). I need to create a template that wasn't provided and am unfamiliar with the process. Has this been documented for the contacts sample?? Please advise.
  21. MC Sep 12, 2008
    Shouldn't someone clean up this blog? All the porn spam at the bottom does SiteFinity no favours at all. I've come here to research SiteFinity CMS but all the material I've dragged up (including this blog, the fact that the SiteFinity.com web site does not function correctly in Firefox and that the online demo shows the Telerik University web site with a menu item of "ContactUs", not "Contact Us") has completely put me off the product. I can't imagine it would be anything but entirely full of bugs and it does not surprise me that people can't get their own controls to work with it.

    Leave a comment