Echilon
Echilon

Reputation: 10244

ASP.NET - Web Application, UserControls and NullReferenceExceptions

I have a web application, which works fine if I include my user controls with

<%@ Register TagPrefix="mine" TagName="MyUC1" Src="~/UserControls/MyUc1.ascx" %>
<%@ Register TagPrefix="mine" TagName="MyUC2" Src="~/UserControls/MyUc2.ascx" %>

But I need to use the namespace due to needing to integrate with Umbraco. When I replace the register declaration with:

<%@ Register TagPrefix="mine" Namespace="MyAssembly.UserControls" Assembly="MyAssembly"%>

I get a null reference exception in the UserControl's Page_Load event (which references an ASP.NET control which is used by the UserControl itself.

I find this pretty bizarre, but I've found very little information on how to fix it.

Upvotes: 2

Views: 511

Answers (1)

Janusz Skonieczny
Janusz Skonieczny

Reputation: 18982

Did you try to put references inside Web.config file?

Like this:

<compilation debug="true">
  <assemblies>
    [...]
    <add assembly="DevExpress.Web.ASPxEditors.v8.3" />
  </assemblies>
</compilation>

UPDATE:

Then maybe you can also register your controls in Web.config, like this:

<pages theme="Default">
  <controls>
    [...]
    <add assembly="DevExpress.Web.ASPxEditors.v8.3" namespace="DevExpress.Web.ASPxGridView" tagPrefix="dxe" />
  </controls>
</pages>

Upvotes: 1

Related Questions