DotNetNuke 4.3.5 StarterKit C#模板无法运行Bug
首先会出现这样的错误提示:
按照提示,找到出错的代码,第136行,很明显,作者按照VB的语法在连接字符串。
之后,会出现这样的出错提示:
对于这个出错先介绍一个简单的解决方案:
如果出现这个提示,并不表示现在模块完全不能使用,这时你点左上角的小三角形进入“设置”页,点击模块对应的设置节,在“Template"处输入"[CONTENT]"并更新,模块就可以正常运行,有时间会做个补丁。
Error: TesingModulle is currently unavailable.
DotNetNuke.Services.Exceptions.ModuleLoadException: e:\Development\DotNetNuke_4.3.5_Source\Website\DesktopModules\TestingModule\ViewTestingModule.ascx.cs(136): error CS0019: Operator '&' cannot be applied to operands of type 'string' and 'string' ---> System.Web.HttpCompileException: e:\Development\DotNetNuke_4.3.5_Source\Website\DesktopModules\TestingModule\ViewTestingModule.ascx.cs(136): error CS0019: Operator '&' cannot be applied to operands of type 'string' and 'string' (运算符“&”无法应用于“string”和“string”类型的操作数)at System.Web.Compilation.AssemblyBuilder.Compile() at System.Web.Compilation.BuildProvidersCompiler.PerformBuild() at System.Web.Compilation.BuildManager.CompileWebFile(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) in E:\Development\DotNetNuke_4.3.5_Source\Library\Components\Skins\Skin.vb:line 446 --- End of inner exception stack trace ---
DotNetNuke.Services.Exceptions.ModuleLoadException: e:\Development\DotNetNuke_4.3.5_Source\Website\DesktopModules\TestingModule\ViewTestingModule.ascx.cs(136): error CS0019: Operator '&' cannot be applied to operands of type 'string' and 'string' ---> System.Web.HttpCompileException: e:\Development\DotNetNuke_4.3.5_Source\Website\DesktopModules\TestingModule\ViewTestingModule.ascx.cs(136): error CS0019: Operator '&' cannot be applied to operands of type 'string' and 'string' (运算符“&”无法应用于“string”和“string”类型的操作数)at System.Web.Compilation.AssemblyBuilder.Compile() at System.Web.Compilation.BuildProvidersCompiler.PerformBuild() at System.Web.Compilation.BuildManager.CompileWebFile(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) in E:\Development\DotNetNuke_4.3.5_Source\Library\Components\Skins\Skin.vb:line 446 --- End of inner exception stack trace ---
按照提示,找到出错的代码,第136行,很明显,作者按照VB的语法在连接字符串。
foreach (PropertyInfo objPropertyInfo in objProperties)
& nbsp; {
136行: if (strContent.IndexOf("[" & objPropertyInfo.Name.ToUpper() & "]") != -1)
{
strValue = Server.HtmlDecode(DataBinder.Eval(e.Item.DataItem, objPropertyInfo.Name).ToString());
strContent = strContent.Replace("[" + objPropertyInfo.Name.ToUpper() + "]", strValue);
}
}
将"&"改为“+"。& nbsp; {
136行: if (strContent.IndexOf("[" & objPropertyInfo.Name.ToUpper() & "]") != -1)
{
strValue = Server.HtmlDecode(DataBinder.Eval(e.Item.DataItem, objPropertyInfo.Name).ToString());
strContent = strContent.Replace("[" + objPropertyInfo.Name.ToUpper() + "]", strValue);
}
}
之后,会出现这样的出错提示:
Error: TesingModulle is currently
unavailable.
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 YourCompany.Modules.TestingModule.ViewTestingModule.lstContent_ItemDataBound(Object sender, DataListItemEventArgs e) in e:\Development\DotNetNuke_4.3.5_Source\Website\DesktopModules\TestingModule\ViewTestingModule.ascx.cs:line 136 at System.Web.UI.WebControls.DataList.OnItemDataBound(DataListItemEventArgs e) at System.Web.UI.WebControls.DataList.CreateItem(Int32 itemIndex, ListItemType itemType, Boolean dataBind, Object dataItem) at System.Web.UI.WebControls.DataList.CreateControlHierarchy(Boolean useDataSource) at System.Web.UI.WebControls.BaseDataList.OnDataBinding(EventArgs e) at System.Web.UI.WebControls.BaseDataList.DataBind() at YourCompany.Modules.TestingModule.ViewTestingModule.Page_Load(Object sender, EventArgs e) in e:\Development\DotNetNuke_4.3.5_Source\Website\DesktopModules\TestingModule\ViewTestingModule.ascx.cs:line 115 --- End of inner exception stack trace ---
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 YourCompany.Modules.TestingModule.ViewTestingModule.lstContent_ItemDataBound(Object sender, DataListItemEventArgs e) in e:\Development\DotNetNuke_4.3.5_Source\Website\DesktopModules\TestingModule\ViewTestingModule.ascx.cs:line 136 at System.Web.UI.WebControls.DataList.OnItemDataBound(DataListItemEventArgs e) at System.Web.UI.WebControls.DataList.CreateItem(Int32 itemIndex, ListItemType itemType, Boolean dataBind, Object dataItem) at System.Web.UI.WebControls.DataList.CreateControlHierarchy(Boolean useDataSource) at System.Web.UI.WebControls.BaseDataList.OnDataBinding(EventArgs e) at System.Web.UI.WebControls.BaseDataList.DataBind() at YourCompany.Modules.TestingModule.ViewTestingModule.Page_Load(Object sender, EventArgs e) in e:\Development\DotNetNuke_4.3.5_Source\Website\DesktopModules\TestingModule\ViewTestingModule.ascx.cs:line 115 --- End of inner exception stack trace ---
对于这个出错先介绍一个简单的解决方案:
如果出现这个提示,并不表示现在模块完全不能使用,这时你点左上角的小三角形进入“设置”页,点击模块对应的设置节,在“Template"处输入"[CONTENT]"并更新,模块就可以正常运行,有时间会做个补丁。