G
giladap
I am trying to create a BHO using C#. I currently have it successfully
loading into IE (I've checked with "Manage Add-ons"), but nothing else
seems to be working. I get no errors that I can see.
I have the BHO trying to write to a text file. It is creating the text
file ("log.txt") when IE loads, but nothing is being written to it. What
might I be missing?
Below are the relevant snippets code. First, my declaration for the COM
interface "IObjectWithSite":
// The interface
[
ComImport(),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown),
Guid("FC5971A5-C2D2-4442-9778-E924303A3399")
]
public interface IObjectWithSite
{
[PreserveSig]
int SetSite ([MarshalAs(UnmanagedType.IUnknown)]object site);
[PreserveSig]
int GetSite (ref Guid guid, out IntPtr ppvSite);
}
I've instantiated the object as follows:
// The object
[
ComVisible(true),
Guid("B5309629-6A3B-4e80-9C74-8A18F43E059A"),
ClassInterface(ClassInterfaceType.None)
]
public class BHO : IObjectWithSite
{
And the constructor is below. Note that "log.txt" is being created when
the constructor runs, but the very next line of code tries to write to
the file--and nothing occurs.
public BHO()
{
redirPagePath = typeof(DnsFilter).Assembly.Location;
redirPagePath = Path.Combine(Path.GetDirectoryName(redirPagePath),
"html\\blocked.html");
logFile = new StreamWriter(
Path.Combine(Path.GetDirectoryName(redirPagePath), "log.txt" ),false);
logFile.WriteLine(" Log Initialized");
}
What might I be missing? Any help would be appreciated. Thanks,
J.A.
loading into IE (I've checked with "Manage Add-ons"), but nothing else
seems to be working. I get no errors that I can see.
I have the BHO trying to write to a text file. It is creating the text
file ("log.txt") when IE loads, but nothing is being written to it. What
might I be missing?
Below are the relevant snippets code. First, my declaration for the COM
interface "IObjectWithSite":
// The interface
[
ComImport(),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown),
Guid("FC5971A5-C2D2-4442-9778-E924303A3399")
]
public interface IObjectWithSite
{
[PreserveSig]
int SetSite ([MarshalAs(UnmanagedType.IUnknown)]object site);
[PreserveSig]
int GetSite (ref Guid guid, out IntPtr ppvSite);
}
I've instantiated the object as follows:
// The object
[
ComVisible(true),
Guid("B5309629-6A3B-4e80-9C74-8A18F43E059A"),
ClassInterface(ClassInterfaceType.None)
]
public class BHO : IObjectWithSite
{
And the constructor is below. Note that "log.txt" is being created when
the constructor runs, but the very next line of code tries to write to
the file--and nothing occurs.
public BHO()
{
redirPagePath = typeof(DnsFilter).Assembly.Location;
redirPagePath = Path.Combine(Path.GetDirectoryName(redirPagePath),
"html\\blocked.html");
logFile = new StreamWriter(
Path.Combine(Path.GetDirectoryName(redirPagePath), "log.txt" ),false);
logFile.WriteLine(" Log Initialized");
}
What might I be missing? Any help would be appreciated. Thanks,
J.A.