Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ajax Assembly Error - Assembly {0} does not contain a Web resource with name {1}

I have an assembly that contains an embedded resource. However, when this assembly is accessed via the web, I get the following error:

Assembly 'MyAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' does not contain a Web resource with name 'MyAssembly.MyScript.js'.

Ironically enough, if I write an app that uses reflection to look at the resources, the name of the script file is 'MyAssembly.MyScript.js'.

Here's the stack:

[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

Thanks in advance for any assistance!

like image 217
Jason N. Gaylord Avatar asked Nov 03 '09 19:11

Jason N. Gaylord


1 Answers

Add this line of code to your AssemblyInfo.cs file

[assembly: System.Web.UI.WebResource("MyAssembly.MyScript.js", "text/javascript")]
like image 178
Max Avatar answered Sep 30 '22 18:09

Max