Damian Mehers' Blog Android, VR and Wearables from Geneva, Switzerland.

22Feb/0717

Dealing with “Assembly x contains a Web resource with name x, but does not contain an embedded resource with name x. “

I got the go-ahead to move the ListSearchExtender from the prototype branch of the AJAX Control Toolkit to the development branch, and everything was going swimmingly until I got this error when running:
Assembly 'AjaxControlToolkit, Version=1.0.10201.0, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e' contains a Web resource with name 'AjaxControlToolkit.ListSearchBehavior.js', but does not contain an embedded resource with name 'AjaxControlToolkit.ListSearchBehavior.js'.

I checked, and yes my ListSearchBehavior.js file did have its Build Action property set to Embedded Resource so the solution wasn't that easy.

Next I fired up the ildasm tool that comes with the .NET SDK and double-clicked on the manifest. Here I got a clue as to what was happening. It showed that the embedded resource was called AjaxControlToolkit.ListSearchBehavior.ListSearchBehavior.js whereas all the others were called things like AjaxControlToolkit.DropShadow.DropShadowBehavior.js

I went digging in my code and sure enough, I'd screwed up my assembly and ClientScriptResource attributes. This is the corrected version (the bold bits used to say ListSearchBehavior):

[assembly: WebResource("AjaxControlToolkit.ListSearch.ListSearchBehavior.js", "text/javascript")]
namespace AjaxControlToolkit
{
...
[ClientScriptResource("AjaxControlToolkit.ListSearchBehavior", "AjaxControlToolkit.ListSearch.ListSearchBehavior.js")]
...
public class ListSearchExtender : ExtenderControlBase

Hopefully this post will save others that are banging their heads against the wall with the same error.

Filed under: AJAX Leave a comment
Comments (17) Trackbacks (2)
  1. Thanks, that helped πŸ™‚

  2. Thanks for this post … the issue was just kinng me

  3. In spanish

    si el proyecto se creo con el icono ASP.NET AJAX control Project. que instala la herramienta AjaxControlExtender.vsi.
    Los archivos de compilacion embedded los referencia en el archivo projectName.vbproj. si este archivo se abre con el NotePad y se busca la etiqueta

    .
    .

    La cual se crea por defecto cuando se crea el proyecto, el problema surge cuando se va a agregar un nuevo Extender en el mismo dll. No se agrega la etiqueta adecuada.

    se puede agregar una linea como, donde el js hace referencia al segundo control, tercero, etc.

    Se recompila y listo se soluciona el problema

    De colombia para el mundo
    Juan Pablo Manrique

  4. In spanish

    en mi comentario anterior me elimino las etiquetas asi que va de nuevo con (: πŸ™‚

    si el proyecto se creo con el icono ASP.NET AJAX control Project. que instala la herramienta AjaxControlExtender.vsi.
    Los archivos de compilacion embedded los referencia en el archivo projectName.vbproj. si este archivo se abre con el NotePad y se busca la etiqueta
    (:ItemGroup:)
    (:EmbeddedResource Include=”otroBehavior.js” /:)
    .
    .
    (:/ItemGroup:)
    La cual se crea por defecto cuando se crea el proyecto, el problema surge cuando se va a agregar un nuevo Extender en el mismo dll. No se agrega la etiqueta adecuada.

    se puede agregar una linea como, donde el js hace referencia al segundo control, tercero, etc.
    (:EmbeddedResource Include=”MyControl1Behavior.js” /:)
    Se recompila y listo se soluciona el problema

    De colombia para el mundo
    Juan Pablo Manrique

  5. Thank you very much for this post. It helped me figure out what was happening when this same thing was occurring to me.

  6. Dude, in my case I was receiving an error

    “…contains a Web resource with name …but does not contain an embedded resource with name …”

    and the solutions was tricky but easy.

    it’s quite simple, in Visual Studio 2005 just right-click the .js file and choose Properties.

    On property window, locate Build Action attribute and set it to “Embedded Resource”. The problem was happining because it was accidentally to “Compile” (not by me *LOL*).

    My folders are:

    – MyControlToolkit (c# project)
    – HelloExtender (folder)
    – HelloBehavior.js (file)
    – HelloDesigner.cs (file)
    – HelloExtender.cs (file)

    Below a piece of my source code on HelloExtender.cs:

    using System;
    using System.Web.UI.WebControls;
    using System.Web.UI;
    using System.ComponentModel;
    using System.ComponentModel.Design;
    using AjaxControlToolkit;

    [assembly: System.Web.UI.WebResource(“MyControlToolkit.HelloExtender.OlaBehavior.js”, “text/javascript”)]

    namespace MyControlToolkit
    {
    [Description(“Show hello message to user”)]
    [Designer(typeof(HelloDesigner))]
    [ClientScriptResource(“MyControlToolkit.HelloBehavior”, “StarjobsControlToolkit.HelloExtender.HelloBehavior.js”)]
    [TargetControlType(typeof(Control))]
    [RequiredScript(typeof(CommonToolkitScripts), 0)]
    public class OlaExtender : ExtenderControlBase {
    // TODO: Add your property accessors here.
    //
    [ExtenderControlProperty]
    [DefaultValue(“”)]
    public string MyProperty
    {
    get
    {
    return GetPropertyValue(“MyProperty”, “”);
    }
    set
    {
    SetPropertyValue(“MyProperty”, value);
    }
    }
    }

    I hope this tip help many others over the world!

    cheers,
    Wander Mahet
    Rio de Janeiro, Brazil

  7. thanks very helpful, that was the problem i had

  8. Many thanks – sorted out the issue i had πŸ™‚

  9. This really really helped me. Many Thanks

  10. This really really helped me. Many Thanks

  11. Thanks. Fixed the problem I was having.

  12. In my code, only the CASE of the namespace was different, but your post helped find the issue. A namespace of AJAXControlExtenders in VB is NOT the same as ‘AjaxControlExtenders’ in Javascript, and vice versa…

  13. I had a similar issue but my problem wasn’t the code. It took me awhile, but the Assembly Name and Namespace Name in my Project’s Properties weren’t matching up with what I was using in the code.

    (For what it’s worth, I was following a tutorial online but after creating the control, I decided to substitute names to make more sense for our application… hence, all the name discrepancy.)

  14. Thanks…It helped me πŸ™‚

  15. Thanks helped me out a hole.


Leave a comment