Ajax程序集错误 - 程序集{0}不包含名为{1}的Web资源

时间:2009-11-03 19:31:05

标签: asp.net ajax asp.net-ajax embedded-resource

我有一个包含嵌入资源的程序集。但是,当通过Web访问此程序集时,我收到以下错误:

  

程序集'MyAssembly,Version = 1.0.0.0,Culture = neutral,   PublicKeyToken = null'不包含具有名称的Web资源   'MyAssembly.MyScript.js'。

具有讽刺意味的是,如果我编写一个使用反射来查看资源的应用程序,则脚本文件的名称为“MyAssembly.MyScript.js”。

这是堆栈:

[InvalidOperationException: Assembly 'MyAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' does not contain a Web resource with name 'MyAssembly.MyScript.js'.]
   System.Web.UI.WebResourceUtil.VerifyAssemblyContainsReleaseWebResource(Assembly assembly, String releaseResourceName) +614706
   System.Web.UI.ScriptReference.ShouldUseDebugScript(String releaseName, Assembly assembly, Boolean isDebuggingEnabled) +85
   System.Web.UI.ScriptReference.GetResourceName(String releaseName, Assembly assembly, Boolean isDebuggingEnabled) +16
   System.Web.UI.ScriptReference.GetUrlFromName(ScriptManager scriptManager, IControl scriptManagerControl, Boolean zip) +80
   System.Web.UI.ScriptManager.RegisterUniqueScripts(List`1 uniqueScripts) +169
   System.Web.UI.ScriptManager.RegisterScripts() +407
   System.Web.UI.ScriptManager.OnPagePreRenderComplete(Object sender, EventArgs e) +200
   System.Web.UI.Page.OnPreRenderComplete(EventArgs e) +11039454
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3672

提前感谢您的任何帮助!

1 个答案:

答案 0 :(得分:16)

将此行代码添加到AssemblyInfo.cs文件

[assembly: System.Web.UI.WebResource("MyAssembly.MyScript.js", "text/javascript")]