Add a BHO image resource to the DOM using C# RRS feed

  • Question

  • I posted this problem a couple of days ago on another site, but realized that this is completely a microsoft question and so I think I may have better luck here on these forums. Any help would be appreciated.

    I am running Vista Home Premium with C# Express 2010

    I am having trouble loading a WIN32 resource image from my C# BHO into the DOM when IE loads a page. I would appreciate some help in identifying where the problem and how to fix it.

    I am starting with the code found here:


    I can get the code to install, and IE to execute javascript on pages as they load. I have an image that I want to add to the DOM. currently the code I am using to try and and add the image is:

        string img = "<img id=\"BHOimg\" src=\"res://BHOHelloWorld.dll/#2/LOGO.bmp\">";
        document.body.insertAdjacentHTML("afterBegin", img);

    where BHOHelloWorld.dll is the BHO this code is from. With this approach the image node  is added to the DOM, but the image is a red X. I have looked in the BHOHelloWorld.dll once it is compiled using PE Explorer and can see the logo.bmp resource. The fact that I can see the image leads me to believe that the src attribute is wrong. it is worth noting that when I use PE Explorer the image name is LOGO.BMP instead of LOGO.BMP

    BHOHelloWorld was compiled utilizing the following these steps:

    starting here:


    I have created an RC file (nativeresources.rc) with the following content:

    logo.bmp bitmap "logo.bmp"

    I then added 

    "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\rc.exe" /r "../../nativeresources.rc"

    to my prebuild events for my project.

    I have also added


    to my csproj file on the advice of this link


    I am compiling my BHOHelloWorld project using csc.exe on the command line, because MS told me that I have to use the /win32res flag and that the VS IDE didn't support it.


    To get the right csc.exe command I changed C# Express output to be verbose and compiled. I then just copied it the csc command from the output window to the commandline and added 


    Everything seems to compile and embed fine in that rc.exe creates a .res file without throwing any errors. The res file is only slightly bigger than the image file, and  once I have built the BHOHelloWorld.dll file, I can open it with PE Explorer and can see the image in question albeit with a slightly different name of LOGO.BMP. I am not sure if this is an artifact of PE Explorer, or a problem with the way I compiled / embedded. In any event I have tried replacing the image src attribute to reflect the different name with no luck. I have now spent a couple of days on this and feel stuck. any help would be appreciated.

    • Moved by Eason_H Monday, December 2, 2013 6:16 AM
    Monday, December 2, 2013 12:37 AM

All replies

  • Hi Isingmodel,

    Since the issue regards ASP.NET and website deployment. I suggestion you post the question in the ASP.NET forums at http://forums.asp.net/. It is appropriate and more experts will assist you.

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, December 2, 2013 6:16 AM
  • To be clear I am talking about a problem with a BHO - a client side extension technology for IE. I am not sure how that is a ASP.NET question. Could you please clarify.

    Monday, December 2, 2013 11:28 PM