The Dreaded “Not a Known Element” Error

Element ‘{name}’ is not a known element.  This can occur if there is a compilation error in the Web site, or the web.config is missing.

If you’ve ever seen this error and started pulling your hair to solve it; this post is for you.

Let’s say you’re building a custom module for DotNetNuke website.  You want to take advantage of the DotNetNuke wrapper for the Telerik controls.  You register the component

<%@ Register TagPrefix=”dnnUI” Assembly=”DotNetNuke.Web” Namespace=”DotNetNuke.Web.UI.WebControls” %>

You attempt to add the control, but the Intellisense is missing. No problem.  You find an example of the control, add it to your code and modify it. It’s the old “Copy, Paste, Modify” routine.

<dnnUI:DnnGrid ID=”grdSummary” runat=”server” ShowHeader=”true” ShowFooter=”true” GroupingEnabled=”true” >

Everything looks good, but pretty soon this happens

NotAKnownElementIt’s the dreaded squiggly green underline accompanied by an error that leads you on a wild goose chase.  You have no compilation errors.  The site runs fine, so the web.config isn’t missing.  What’s the problem?

The problem is that your custom project cannot find the Telerik dll’s, or the DotNetNuke wrappers for them.  But you say you’ve made the references so it should know.

If you are building your custom module in the standard way the module project is located in the DesktopModules folder of the website.  The compiled DLL for the project is located in the bin folder which sits at the same level in the heirarchy as the DesktopModules folder.  When you run the site the server reads the dlls from the bin location of the site, not the project.  When you’re working on the module project in Visual Studio and that project is loaded by itself, the project isn’t looking for the DLL’s in the site bin folder even when you reference them.  You’re custom module project is looking for the dll’s in the project bin folder.  If they aren’t there, the project can’t find them.

Here’s the solution.  It’s very simple and poorly documented.

Step 1: Add a bin folder

Create a bin folder for the project. If you’re project is at /DesktopModules/MyProject then create the folder /DesktopModules/MyProject/bin

Step 2: Add the wrapper dll’s to the bin folder

Add the following dll’s to the bin folder:

  1. DotNetNuke.dll
  2. DotNetNuke.Web.dll
  3. DotNetNuke.WebControls.dll
  4. Telerik.Web.UI.dll

No need to register, or reference, them.  Just copy and paste right into the folder.  If you have multiple custom module projects you need to add this bin folder with the dll’s to each and every project.

Step 3: Add the Registration tags to your page

In your page you need to register two sets of controls even if you only use one.

<%@ Register TagPrefix="dnnWeb" Assembly="DotNetNuke" Namespace="DotNetNuke.UI.WebControls" %>
<%@ Register TagPrefix="dnnUI" Assembly="DotNetNuke.Web" Namespace="DotNetNuke.Web.UI.WebControls" %>

You can change the TagPrefix to whatever you prefer.

That’s it.  You should now have Intellisense in your project for the DotNetNuke wrapped Telerik controls and the green squiggly warning should be gone.

Let me know if this works for you!

7 comments for “The Dreaded “Not a Known Element” Error

  1. February 24, 2015 at 2:01 pm

    Hello, I tested your solution and it worked for me 😀 … for a while 🙁

    After several days it stopped working for one of my modules, repeating the steps doesn’t seem to work.

    If you’ve faced this issue before and know a solution, please, tell us.

    If I find one, I’ll post it here.

    Thanks.

    • March 9, 2015 at 2:47 pm

      My first thought is if you added more modules to the solution than perhaps one of the modules doesn’t have all the dll’s in it’s project bin folder.

      Otherwise, did anything change in the project?

  2. Dave Davis
    July 10, 2015 at 7:24 pm

    Finally!!! Someone who knows what he’s talking about. I’ve been pulling my hair on this issue for a while now. Read more posted suggestions than I can count. None worked…. Thanks Cliff……

  3. May 16, 2016 at 4:12 am

    Hi Cliff thanks for this. I have a problem with existing code I wrote that now breaks when I use your method. I suspect its the way a control is being called.

    String text = Page.Request.Form[“datepicker”];
    datepicker.SelectedDate = t.UserSelectedDate;

    Now I’m getting a compile error on the second line of code:

    “The name “datepicker” does not exist in the current context”

    Could you help?

    • June 8, 2016 at 3:09 pm

      Jonathan,

      In the case of those two lines you wrote ‘datepicker’ would need to be the ID of a DatePicker control.

      But it looks like you’re trying to get the date from the control and then reassign it to the control.

      What is it your trying to accomplish?

      -Cliff

Leave a Reply