Using embedded resources as background images causes designer errors. RRS feed

  • Question

  • I'm using Visual Studio 2005.  Everytime I use a resource file as a background image on a button, the next time I try to load the form, I receive a designer error saying something along the line of this:


    The type '[Project Namespace].My.Resources.Resources' has no property named 'buttonbackground'


    For every instance of a resource file being used in that form. the resources are there and intellisense will even pick them up.


    This problem has been lingering around for a while now, and we've managed to keep working on the project with several work-arounds that we have found to bypass the problem, however, the issue seems to be getting worse.


    I've looked at this posting here: but My Namespaces seem to be fine, and there are no duplicates. 


    I've also seen solutions saying that I should give the namespace of the resource file something other than My.Resources.  the logic behind this was that if you have more than one project in your solution, there is a bug in Visual Studio that can cause it to sometimes get confused and look at the wrong resource file, and changing the namespace of the resource file will make this impossible as they will not all be referenced as My.Resources.  This did not work for me either.


    I've also seen solutions that say if you delete the 'obj' folder from the project and rebuild the solution it will fix up the resource file error.   This seems to work some of the time for me, but not always and it's extremely annoying.  I've gone through this process for over fifteen minutes; deleting the obj folder, cleaning the solution and rebuilding the solution, all the while opening the form at different random point in the process until it finally works. (I've yet to find a consistancy to this process or make it work on a regular basis).


    after all this I've then left with going into the designer code file and either commenting out the resource references and uncommenting them after, or removing them and re-adding them back in through the designer.  This will always work for me but is also a real hassle and can take a lot of time.


    here is my Visual Studio information if it helps.


    Microsoft Visual Studio 2005
    Version 8.0.50727.762  (SP.050727-7600)
    Microsoft .NET Framework
    Version 2.0.50727 SP1

    Installed Edition: Enterprise


    Microsoft Visual Studio 2005 Team Suite - ENU Service Pack 1 (KB926601)  
    This service pack is for Microsoft Visual Studio 2005 Team Suite - ENU.
    If you later install a more recent service pack, this service pack will be uninstalled automatically.
    For more information, visit

    Security Update for Microsoft Visual Studio 2005 Team Suite - ENU (KB937061)  
    This Security Update is for Microsoft Visual Studio 2005 Team Suite - ENU.
    If you later install a more recent service pack, this Security Update will be uninstalled automatically.
    For more information, visit


    Any help on this issue would be greatly appreciated.  Thanks in advance.
    Tuesday, January 22, 2008 6:15 PM



    Hi Blatz,

    Yes, it the namespace cause the problem. I can reproduce this problem with the following steps.

    1.       Create a new C# windows application project.

    2.       Build your application and copy the [projectfolder]\obj\Debug\[projectname].exe file to [projectfolder]\

    3.       Add a reference the [projectfolder] \[projectname].exe file.

    4.       Add a button with a background image using the Project resource file to Form2 and save it

    5.       Open the Form1, you will see the error.

    6.       Delete the reference to [projectfolder] \[projectname].exe file will solve the problem.

    For more information about this error, you can use the Object Browser to see the structure of you project and the [Project Namespace].Properties.Resources. You will see the new added image is not contained in the resources.

    Hope this helps.
    Best regards.
    Rong-Chun Zhang

    Friday, January 25, 2008 11:05 AM