Identifying URL of Web Page that .NET ActiveX is running within
-
I thought this would be a relatively easy task but it is turning out to be surprisingly difficult. I would like to create an ActiveX control that can be embedded into a web-page and knows what the URL of the web-page it is embedded in is. Some googling around lead me the SHDocVw COM library (ugh) which seems like an overly complicated solution, but my options seemed few. However, using code such as: SHDocVw.IWebBrowser2 tmp = (SHDocVw.IWebBrowser2)System.Runtime.InteropServices.Marshal.GetActiveObject("InternetExplorer.Application"); (Or the ShellWindows-based solution) and an Object tag (HTML) such as Allows the original C# class/form to appear but fails as soon as the line above is executed. The failure is System.IO.FileNotFoundException: Could not load file or assembly 'Interop.SHDocVw, Version=1.1.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified. File name: 'Interop.SHDocVw, Version=1.1.0.0, Culture=neutral, PublicKeyToken=null' Although the Interop.SHDocVW .dll is in the same directory (how to package two DLLs for ActiveX-via-.NET ... I thought CABs weren't used for .NET ActiveX and if they are, how to reference the classid?). Any help is greatly appreciated.