
百度翻译此文有道翻译此文
问 题
My asp.net site allows users to pick the theme they want from a list generated from the app_themes folder. From time to time, themes are renamed or removed. Any user who has selected a deleted theme name (it is stored in a cookie) will get the exception:
Theme 'XXX' cannot be found in the application or global theme directories Stack Trace: [HttpException (0x80004005): Theme 'test' cannot be found in the application or global theme directories.] System.Web.Compilation.ThemeDirectoryCompiler.GetThemeBuildResultType(String themeName) +920 System.Web.Compilation.ThemeDirectoryCompiler.GetThemeBuildResultType(HttpContext context, String themeName) +73 System.Web.UI.Page.InitializeThemes() +8699455 System.Web.UI.Page.PerformPreInit() +38 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +282
Where is the best place to trap and handle this exception?
解决方案
In the Page_PreInit method where you assign themes, there's a couple of ways to deal with it. What I do is check to make sure that the directory exists. If it does, then that's the theme I want. If it doesn't, then use a default theme where I know the directory exists.
void Page_PreInit(object sender, EventArgs e)
{
if (ViewState["PageTheme"] == null)
{
if (!Directory.Exists("~/App_Themes/THEMENAME_TO_LOOK_FOR"))
{
Theme = "DEFAULT_THEME"
}
else
{
Theme = "THEMENAME_TO_LOOK_FOR";
}
ViewState["PageTheme"] = Theme;
}
else
{
Theme = ViewState["PageTheme"].ToString();
}
}
I usually store in the viewstate so I don't have to recheck every time but if you're changing themes on-the-fly, then you'll probably need to not do that.
本文地址:IT屋 Theme 'XXX' cannot be found in the application or global theme directories
问 题
我的asp.net网站允许用户挑选她们想要的主题,从App_Themes文件文件夹中生成一个列表。不时,主题被重命名或删除。谁将要选择了一个已删除的主题名称(它是存储在cookie中)的任何用户会受到一个异常:
主题'XXX'不能在应用程序或全局主题目录中找到
堆栈跟踪:
[HttpException(0x80004005的):主题测试”无法在应用程序或全局主题目录中找到]
System.Web.Compilation.ThemeDirectoryCompiler.GetThemeBuildResultType(字符串THEMENAME)920
System.Web.Compilation.ThemeDirectoryCompiler.GetThemeBuildResultType(HttpContext的背景下,字符串THEMENAME)+73
System.Web.UI.Page.InitializeThemes()8699455
System.Web.UI.Page.Perform preINIT()+38
System.Web.UI.Page.ProcessRequestMain(布尔includeStagesBeforeAsyncPoint,布尔includeStagesAfterAsyncPoint)+282
哪里是陷阱里最好的地方,处理这个异常?
解决方案
在哪里分配主题Page_ preINIT方法wince主题软件,有几种方法来对抗它。我应做的就是检查,以保证该目录存在。如果确实这么,那么这就是我想要的主题。如果没有,则使用一个默认的主题,我知道该目录存在。
无效Page_ preINIT(对象发件人,EventArgs的发送)
{
如果(的ViewState [PageTheme”] == NULL)
{
如果(!Directory.Exists(〜/ App_Themes文件/ THEMENAME_TO_LOOK_FOR”))
{
主题=DEFAULT_THEME”
}
其他
{
主题=THEMENAME_TO_LOOK_FOR”;
}
的ViewState [PageTheme”] =主题;
}
其他
{
。主题=的ViewState [PageTheme”]的ToString();
}
}
我常常在ViewState中存储,所以我不必再检查每一次,但即使你改变对即时主题,那么你或许应该这样做。

本文地址:IT屋 主题'XXX'不能在应用程序或全局主题目录中找到

扫一扫关注IT屋
微信公众号搜索 “ IT屋 ” ,选择关注
与百万开发者在一起
官方交流群:
Google Facebook Youtube 科学上网》戳这里《
百度翻译此文有道翻译此文
问 题

我的asp.net网站允许用户挑选她们想要的主题,从App_Themes文件文件夹中生成一个列表。不时,主题被重命名或删除。谁将要选择了一个已删除的主题名称(它是存储在cookie中)的任何用户会受到一个异常:
主题'XXX'不能在应用程序或全局主题目录中找到
堆栈跟踪:
[HttpException(0x80004005的):主题“测试”无法在应用程序或全局主题目录中找到]
System.Web.Compilation.ThemeDirectoryCompiler.GetThemeBuildResultType(字符串THEMENAME)920
System.Web.Compilation.ThemeDirectoryCompiler.GetThemeBuildResultType(HttpContext的背景下,字符串THEMENAME)+73
System.Web.UI.Page.InitializeThemes()8699455
System.Web.UI.Page.Perform preINIT()+38
System.Web.UI.Page.ProcessRequestMain(布尔includeStagesBeforeAsyncPoint,布尔includeStagesAfterAsyncPoint)+282
哪里是陷阱里最好的地方,处理这个异常?
解决方案
在哪里分配主题Page_ preINIT方法,有几种方法来对抗它。我应做的就是检查,以保证该目录存在。如果确实这么,那么这就是我想要的主题。如果没有,则使用一个默认的主题,我知道该目录存在。
无效Page_ preINIT(对象发件人,EventArgs的发送)
{
如果(的ViewState [“PageTheme”] == NULL)
{
如果(!Directory.Exists(“〜/ App_Themes文件/ THEMENAME_TO_LOOK_FOR”))
{
主题=“DEFAULT_THEME”
}
其他
{
主题=“THEMENAME_TO_LOOK_FOR”;
}
的ViewState [“PageTheme”] =主题;
}
其他
{
。主题=的ViewState [“PageTheme”]的ToString();
}
}
我常常在ViewState中存储wince主题软件,所以我不必再检查每一次,但即使你改变对即时主题,那么你或许应该这样做。
本文地址:IT屋 主题'XXX'不能在应用程序或全局主题目录中找到
问 题
![]()
My asp.net site allows users to pick the theme they want from a list generated from the app_themes folder. From time to time, themes are renamed or removed. Any user who has selected a deleted theme name (it is stored in a cookie) will get the exception:
Theme 'XXX' cannot be found in the application or global theme directories Stack Trace: [HttpException (0x80004005): Theme 'test' cannot be found in the application or global theme directories.] System.Web.Compilation.ThemeDirectoryCompiler.GetThemeBuildResultType(String themeName) +920 System.Web.Compilation.ThemeDirectoryCompiler.GetThemeBuildResultType(HttpContext context, String themeName) +73 System.Web.UI.Page.InitializeThemes() +8699455 System.Web.UI.Page.PerformPreInit() +38 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +282
Where is the best place to trap and handle this exception?
解决方案
In the Page_PreInit method where you assign themes, there's a couple of ways to deal with it. What I do is check to make sure that the directory exists. If it does, then that's the theme I want. If it doesn't, then use a default theme where I know the directory exists.
void Page_PreInit(object sender, EventArgs e)
{
if (ViewState["PageTheme"] == null)
{
if (!Directory.Exists("~/App_Themes/THEMENAME_TO_LOOK_FOR"))
{
Theme = "DEFAULT_THEME"
}
else
{
Theme = "THEMENAME_TO_LOOK_FOR";
}
ViewState["PageTheme"] = Theme;
}
else
{
Theme = ViewState["PageTheme"].ToString();
}
}
I usually store in the viewstate so I don't have to recheck every time but if you're changing themes on-the-fly, then you'll probably need to not do that.
本文地址:IT屋 Theme 'XXX' cannot be found in the application or global theme directories

扫一扫关注IT屋
微信公众号搜索 “ IT屋 ” ,选择关注与百万开发者在一起
本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/bofangqi/article-137458-1.html
吓死宝宝了
早安
啊