I have built a BHO based on this article and it works great, but I cannot deploy it to machines that do not have Visual Studio 2005. It won't register and I have fixed all the errors that Dependency Walker showed.
Has anyone else had problems deploying
Murph

New MSDN BHO Article - Building Browser Helper Objects with Visual Studio 2005
loken
1. Turn off the "embed manifest" as stated above in the project properties, manifest tool, input/output.
2. Use depends to find out what else you are dynamically linking to. Probably the CRT and ATL. Unless you want to ship all that, make them static.
ck75mk
Yes, I meant to say "Release" not "Retail." (Fixed above.) Old habits die hard.
I would also be interested to know if anyone else is having trouble. I have deployed the BHO to a Windows XP SP2 Pro box without VS2005 and it worked for me--but there may be trouble if the target system isn't running the latest service pack. See http://channel9.msdn.com/ShowPost.aspx PostID=23261.
BTW, the best way to deploy is with a standalone setup that includes the appropriate merge modules. (It's not as hard as you might think.)
http://msdn2.microsoft.com/en-us/library/ms235317(VS.80).aspx
Also, make sure you take the time (it's a doozie) to install the latest service pack for Visual Studio 2005:
http://www.microsoft.com/downloads/details.aspx familyid=BB4A75AB-E2D4-4C96-B39D-37BAF6B5B1DC&displaylang=en
NewbieDude
I have a lot of MessageBox.Show - to help me to understand what's happened in a computer that have no development tools installed.
The green code never executed - and this is good, because that code means exceptions - cached errors
The blue code got executed - this is also good... means that IE run that code!
The red code never executed - is red only in DocumentCompleted function, that is the function that run when the browser finished to load the page! This is wrong, because that part, in my computer, development computer, run. Only in computers without Visual Studio is not running!
Any suggestion What do am I missing
The code for this BHO is:
[ComVisible(true)]
[Guid("0A39EB4C-A152-439c-9A82-15936A2C895C")]
[ClassInterface(ClassInterfaceType.None)]
public class MyBHO : IObjectWithSite
{
WebBrowser webBrowser;
HTMLDocument document;
#region IObjectWithSite Members
public int SetSite(object site)
{
System.Windows.Forms.MessageBox.Show("Entered in SetSite");
if (site != null)
{
try
{
System.Windows.Forms.MessageBox.Show("1");
webBrowser = (WebBrowser)site;
System.Windows.Forms.MessageBox.Show("webBrowser: " + webBrowser.FullName);
webBrowser.DocumentComplete += new DWebBrowserEvents2_DocumentCompleteEventHandler(this.OnDocumentComplete);
System.Windows.Forms.MessageBox.Show("DocumentComplete");
webBrowser.BeforeNavigate2 += new DWebBrowserEvents2_BeforeNavigate2EventHandler(this.OnBeforeNavigate2);
System.Windows.Forms.MessageBox.Show("BeforeNavigate2");
}
catch (Exception ex)
{
System.Windows.Forms.MessageBox.Show(ex.Message);
}
}
else
{
webBrowser.DocumentComplete -= new DWebBrowserEvents2_DocumentCompleteEventHandler(this.OnDocumentComplete);
webBrowser.BeforeNavigate2 -= new DWebBrowserEvents2_BeforeNavigate2EventHandler(this.OnBeforeNavigate2);
webBrowser = null;
}
return 0;
}
public int GetSite(ref Guid guid, out IntPtr ppvSite)
{
System.Windows.Forms.MessageBox.Show("Entered in GetSite");
IntPtr punk = Marshal.GetIUnknownForObject(webBrowser);
int hr = Marshal.QueryInterface(punk, ref guid, out ppvSite);
Marshal.Release(punk);
return hr;
}
#endregion
#region BrowserEvents
void OnDocumentComplete(object pDisp, ref object URL)
{
System.Windows.Forms.MessageBox.Show("Entered in OnDocumentComplete");
}
public void OnBeforeNavigate2(object pDisp, ref object URL, ref object Flags, ref object TargetFrameName, ref object PostData, ref object Headers, ref bool Cancel)
{
System.Windows.Forms.MessageBox.Show("Entered in OnBeforeNavigate2");
}
#endregion
#region ComRegisterFunction
public static string BHOKEYNAME = "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Browser Helper Objects";
[ComRegisterFunction]
public static void RegisterBHO(Type t)
{
RegistryKey key = Registry.LocalMachine.OpenSubKey(BHOKEYNAME, true);
if (key == null)
{
key = Registry.LocalMachine.CreateSubKey(BHOKEYNAME);
}
string guidString = t.GUID.ToString("B");
RegistryKey bhoKey = key.OpenSubKey(guidString, true);
if (bhoKey == null)
{
bhoKey = key.CreateSubKey(guidString);
}
// NoExplorer:dword = 1 prevents the BHO to be loaded by Explorer
string _name = "NoExplorer";
object _value = (object)1;
bhoKey.SetValue(_name, _value);
bhoKey.SetValue("Alright", 1);
key.Close();
bhoKey.Close();
}
[ComUnregisterFunction]
public static void UnregisterBHO(Type t)
{
RegistryKey key = Registry.LocalMachine.OpenSubKey(BHOKEYNAME, true);
string guidString = t.GUID.ToString("B");
if (key != null)
{
key.DeleteSubKey(guidString, false);
}
}
#endregion
}
SilverOak
Nope that didn't work either....I would love to email the project to someone and have you tell me exactly what to do to get it to work.
Ok...I fired up VS2005, said new C++ project, ATL Project...compiled....copied to a non-VS2005 computer...and failed registering. Dependency Walker says I am missing DWMAPI.dll.
Pushpa
Ejele012
I want to issue a challenge to anyone who can follow this article and build the DLL:
http://msdn.microsoft.com/library/default.asp url=/library/en-us/IETechCol/cols/dnexpie/expie_hello_bho.asp then deploy the DLL to a non-VS2005 Windows XP machine.
The person who could figure it out, would be a genius.
MojoRising
Build with Release project settings before deploying the BHO.
The Debug project settings create dependencies on the debug versions of DLLs, which are not normally present on systems without Visual Studio. In addition, VS2005 enforces the use of side-by-side assemblies (WinSxS) making it harder to install missing DLLs. By default, the compiler combines the manifest file with the DLL as a resource; although you can change project settings to create an external file, you cannot disable this feature.
If you are still having trouble, install the MSVCRT redistributable package on the target machine.
http://msdn2.microsoft.com/en-us/library/ms235624(VS.80).aspx
Paul Carruthers
Are you meaning, build with 'Release' settings, not 'Debug' Because I can't find anyplace in VS2005 that would have a 'Retail' setting. Maybe I am missing something. I will try your other suggestion and install the MSVCRT package, and let you know how that goes.
Thank you for your help, I know you and Tony are really busy.
Murph
roisaonua
Man, I have followed every single MSDN page out there on this topic.
Here is my embedded Manifest:
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.VC80.CRT" version="8.0.50727.762" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity>
</dependentAssembly>
</dependency>
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.VC80.ATL" version="8.0.50727.762" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity>
</dependentAssembly>
</dependency>
</assembly>
The RT_MANIFEST is a 2, as it should be. I have ran the vcredist_x86.exe on the target PC. I have used Dependency Walker to verify all dependencies are there...The only problem I see with that is, right on top it says it can't find msvcr80.dll, then below it, it says, c:\windows\winsxs\x86_microsoft.vc80.crt_1fc8b3b9a1e18e3b_8.0.50727.762_x-ww_6b128700\MSVCR80.DLL. How can it not find it, then say it found it
Anyway, So far I am amazed people are still having problems with DLL's. Maybe this should be called "DLL Hell...Side-by-Side". I am also amazed that there are so many people who work for Microsoft who can't seem to help on this.
yanyee
I finally found a correct version of C++ Redist that works. Check the microsoft website and install the latest version. It worked for me.