Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / December 2004

Tip: Looking for answers? Try searching our database.

SetClientSite() and IE 6.0.3790.0 - Win2003 Server

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
R. Kunoth - 23 Dec 2004 09:25 GMT
Hi,

I have got a problem with the webbrowser control - IE Version 6.0.3790.0.  
You only have this version on Win2003 Server (all service packs installed)

The progam runs perfect with the "normal" IE Version 6.0.2900.2180 onto
WinXP, Win2000 -and- Win98/Me ;-)

Intension:
Use webbrowser control in a form and get calls from IHttpSecurity interface
if something is wrong with a certificate without GUI

My solution:
With AxImp /source I created the AxSHDocVw class and implement IHttpSecurity
and IServiceProvider
IServiceProvider is called only if I call SetClientSite(this) -Or-
IProfferService.ProfferService() on XP

Proffer Service works -not- on Win2003 Server :-(
actxprxy.dll exists but I do not get the interface

public class AxWebBrowser : System.Windows.Forms.AxHost,
   COM.IServiceProvider,
   COM.IHttpSecurity
{

static Guid IID_IHttpSecurity = new
Guid("79eac9d7-bafa-11ce-8c82-00aa004ba90b");

// IServiceProvider
   public int QueryService(ref System.Guid guidService, ref System.Guid
guidIID, out IntPtr ppvObject)
   {
     if (guidIID.Equals(IID_IHttpSecurity))
     {
       ppvObject = Marshal.GetComInterfaceForObject(this,
typeof(IHttpSecurity));
       return 0 /*S_OK*/;
     }
     ppvObject = IntPtr.Zero;
     return unchecked( (int) 0x800C0011);
   }

// IHttpSecurity
   public int OnSecurityProblem(int dwProblem)
   {
      [...]
   }

Guid IID_IProfferService = new Guid("cb728b20-f786-11ce-92ad-00aa00a74cd0");
   Guid SID_SProfferService = new
Guid("cb728b20-f786-11ce-92ad-00aa00a74cd0");
   IProfferService _profferService = null;
   int _cookieIHttpSecurity = 0;

   protected override void CreateSink()
   {
     try
     {
       COM.IServiceProvider sp = this.ocx as COM.IServiceProvider;

       if (sp is IProfferService)
       {
         // only XP has it
         IntPtr ipOps;
         IProfferService ps = sp as IProfferService;
         sp.QueryService(ref SID_SProfferService, ref IID_IProfferService,
out ipOps);
         object ops;
         ops = Marshal.GetObjectForIUnknown(ipOps);
         _profferService = ops as COM.IProfferService;
         _profferService.ProfferService(ref IID_IHttpSecurity, this, ref
_cookieIHttpSecurity);
       }
         
       if (0==_cookieIHttpSecurity)
       {
         IOleObject oc = this.ocx as IOleObject;
         oc.SetClientSite(this);
       }

       this.eventMulticaster = new AxWebBrowserEventMulticaster(this);
       this.cookie = new
System.Windows.Forms.AxHost.ConnectionPointCookie(this.ocx,
this.eventMulticaster, typeof(SHDocVw.DWebBrowserEvents2));
     }
     catch (System.Exception e)
     {
        Trace.WriteLine("AxSHDocVw " + e.Message);
        Trace.WriteLine(e.StackTrace);
     }
   }
     
   protected override void DetachSink()
   {
     try
     {
       this.cookie.Disconnect();
       
       if (0!=_cookieIHttpSecurity)
       {
         _profferService.RevokeService(_cookieIHttpSecurity);
         _cookieIHttpSecurity = 0;
       }
       else
       {
         IOleObject oc = this.ocx as IOleObject;
         oc.SetClientSite(null);
       }
     }
     catch (System.Exception e)
     {
         Trace.WriteLine("AxSHDocVw " + e.Message);
         Trace.WriteLine(e.StackTrace);
       }
     }
   }

[...]

Bug:
One instance of the form which includes the webbrowser control runs without
a problem. After destroying it and create a new one InitializeComponent()
-EndInit() throws an exception

"Windowless ActiveX controls are not supported."

public class BrowserForm : System.Windows.Forms.Form
{
[...]

InitializeComponent()
{
...
((System.ComponentModel.ISupportInitialize)(this.axWebBrowser)).EndInit();
...
}
}

Stack Trace:
at System.Windows.Forms.AxHost.InPlaceActivate()
at System.Windows.Forms.AxHost.TransitionUpTo(Int32 state)
at System.Windows.Forms.AxHost.CreateHandle()
at AxSHDocVw.AxWebBrowser.CreateHandle()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.AxHost.EndInit()
at de.fun.GlobalAsax.Browsing.BrowserForm.InitializeComponent()

What i found out:
* If i do not use SetClientSite() it works  - but i do not  get
IServiceProvider-QueryService() calls
* the .Net Versions are identical (the underlying AxHost class in
System.Windows.Forms.dll 1.1.4322.2032 )
* it does not make a difference if I dispose the webbrowser control in the
form or release the interfaces
* the problem is the IE Version 6.0.3790.0 on Win2003 Server

Any ideas to solve the problem?
Is there an other way to get  calls from the IHttpSecurity Interface?
How I can use IProfferService onto Win2003 Server?

Any help will be greatly appreciated.
Ralf
R. Kunoth - 23 Dec 2004 13:51 GMT
Arrggghhhhh, got it

IServiceProvider QueryService return value was wrong if interface is not
implemented!
return unchecked( (int) 0x80004002);  // E_NOINTERFACE

> * the problem is the IE Version 6.0.3790.0 on Win2003 Server
Seems that new IE version on Win 2003 server checks return values in
"better" way  and  together with  .net framework the dispose of web control
is not complete.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.