views:

225

answers:

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!

+1  A: 

Add this line of code to your AssemblyInfo.cs file [assembly: System.Web.UI.WebResource("MyAssembly.MyScript.js", "text/javascript")]

Max
And I had to add the ScriptResource tag to the AssemblyInfo.cs as well. Thanks for the post!
Jason N. Gaylord