After developing and packaging a number of DNN 4 modules in VS2005 using the dynamic compilation model, I thought I'd try the pre-compiled model as outlined by Shaun Walker. Other than the hassle of picking through the precompiled/bin to find all the dlls with the correct hashcode appended names, all seemed to go well with the module installer placing all the pieces in the right folders, running the SQL script, registering the definitions and controls, etc. However, when I attempted to place an instance of the new module on the test page, I received the following exception errors:
InnerException: D:\Clients\C2032\lakeregiontv.org\public_html\DesktopModules\WESNet\ModuleViewDefinitions.ascx(9): error BC30451: Name 'IsEditable' is not declared.
Message: DotNetNuke.Services.Exceptions.ModuleLoadException: D:\Clients\C2032\lakeregiontv.org\public_html\DesktopModules\WESNet\ModuleViewDefinitions.ascx(9): error BC30451: Name 'IsEditable' is not declared. ---> System.Web.HttpCompileException: D:\Clients\C2032\lakeregiontv.org\public_html\DesktopModules\WESNet\ModuleViewDefinitions.ascx(9): error BC30451: Name 'IsEditable' is not declared. at System.Web.Compilation.BuildManager.PostProcessFoundBuildResult(BuildResult result, Boolean keyFromVPP, VirtualPath virtualPath) at System.Web.Compilation.BuildManager.GetBuildResultFromCacheInternal(String cacheKey, Boolean keyFromVPP, VirtualPath virtualPath, Int64 hashCode) at System.Web.Compilation.BuildManager.GetVPathBuildResultFromCacheInternal(VirtualPath virtualPath) at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile) at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile) at System.Web.UI.TemplateControl.LoadControl(VirtualPath virtualPath) at System.Web.UI.TemplateControl.LoadControl(String virtualPath) at DotNetNuke.UI.Skins.Skin.InjectModule(Control objPane, ModuleInfo objModule, PortalSettings PortalSettings) --- End of inner exception stack trace ---
InnerException: Object reference not set to an instance of an object.
Message: DotNetNuke.Services.Exceptions.ModuleLoadException: Object reference not set to an instance of an object. ---> System.NullReferenceException: Object reference not set to an instance of an object. at System.Web.UI.UserControl.get_Request() at DotNetNuke.Entities.Modules.PortalModuleBase.get_IsEditable() at DotNetNuke.UI.Containers.Title.CanEditModule() at DotNetNuke.UI.Containers.Title.Page_Load(Object sender, EventArgs e) --- End of inner exception stack trace ---
The problem stems from this common usage in the .ascx of the IsEditable property which the module control inherits from PortalModuleBase:
<
ItemTemplate>
<asp:HyperLink NavigateUrl='<%# EditURL("desktopmoduleid",DataBinder.Eval(Container.DataItem,"DesktopModuleId")) %>' Visible='<%# IsEditable %>' runat="server" ID="Hyperlink1">
<asp:Image ImageUrl="~/images/edit.gif" AlternateText="Edit" Visible='<%# IsEditable %>' runat="server" ID="Hyperlink1Image" resourcekey="Edit"/>
</asp:HyperLink>
</ItemTemplate>
Further investigation showed that none of the public properties of PortalModuleBase OR those defined in the code file accompanying the .ascx were visible in the .ascx. The module works fine in VB2005 development and works fine when packaged and uploaded to the test site along with the code files accompanying each .ascx using the dynamic compilation model.
When I first received these exceptions, I though that it was because I had packaged the .ascx module control files from the DesktopModules/WESNet folder rather than the modified ones that were created in the precompiled/DesktopModules/WESNet folder that were created when I published the website, the difference being that in the @Control directive, the attribute Inherits="WESNet.DNN.Modules.ModuleViewDefinitions" has been replaced with Inherits="WESNet.DNN.Modules.ModuleViewDefinitions, App_Web_moduleviewdefinitions.ascx.585487ff". The hash code correctly corresponds with that of the pre-compiled codefile which I also verified was correctly getting loaded into the test sites bin folder.
So, once more I settled on using the dynamic compilation model for packaging a DNN 4 module. Has anyone gotten pre-compilation to work in cases where the .ascx module control references a property or method in the accompanying code file or the code file's base class?