コード例 #1
0
ファイル: XappLauncher.cs プロジェクト: sjyanxin/WPFSource
        internal XappLauncherApp(Uri deploymentManifest, string applicationId,
            IBrowserCallbackServices browser, DocObjHost.ApplicationRunnerCallback applicationRunner,
            INativeProgressPage nativeProgressPage,
            string progressPageAssembly, string progressPageClass, string errorPageAssembly, string errorPageClass) 
        {
            _deploymentManifest = deploymentManifest; 
            _applicationId = applicationId; 
            _browser = browser;
            _applicationRunnerCallback = applicationRunner; 
            _fwlinkUri = null;
            this.Startup += new StartupEventHandler(XappLauncherApp_Startup);
            this.Exit += new ExitEventHandler(XappLauncherApp_Exit);
            this.Navigated += new NavigatedEventHandler(XappLauncherApp_Navigated); 

            _nativeProgressPage = nativeProgressPage; 
            _progressPageAssembly = progressPageAssembly; 
            _progressPageClass = progressPageClass;
            _errorPageAssembly = errorPageAssembly; 
            _errorPageClass = errorPageClass;
        }
コード例 #2
0
 internal NativeProgressPageProxy(INativeProgressPage npp)
 {
     _npp = npp;
 }
コード例 #3
0
        int IBrowserHostServices.Run(string path, string fragment, MimeType mime, string debugSecurityZoneURL, string applicationId, object streamContainer, object ucomLoadIStream, HostingFlags hostingFlags, INativeProgressPage nativeProgressPage, string progressAssemblyName, string progressClassName, string errorAssemblyName, string errorClassName, IHostBrowser hostBrowser)
        {
            Invariant.Assert(!string.IsNullOrEmpty(path), "path string should not be null or empty when Run method is called.");
            Invariant.Assert(mime > MimeType.Unknown, "Unknown mime type");
            EventTrace.EasyTraceEvent(EventTrace.Keyword.KeywordPerf | EventTrace.Keyword.KeywordHosting, EventTrace.Event.WpfHost_IBHSRunStart, "\"" + path + "\"", "\"" + applicationId + "\"");
            int num = 0;

            try
            {
                ApplicationProxyInternal.InitData value = this._initData.Value;
                value.HostBrowser       = hostBrowser;
                value.Fragment          = fragment;
                value.UcomLoadIStream   = ucomLoadIStream;
                value.HandleHistoryLoad = true;
                value.MimeType.Value    = mime;
                string  userAgentString = null;
                HRESULT hrLeft          = hostBrowser.GetUserAgentString(out userAgentString);
                if (hrLeft == HRESULT.E_OUTOFMEMORY && (hostingFlags & HostingFlags.hfHostedInIEorWebOC) != (HostingFlags)0)
                {
                    userAgentString = UnsafeNativeMethods.ObtainUserAgentString();
                    hrLeft          = HRESULT.S_OK;
                }
                hrLeft.ThrowIfFailed();
                value.UserAgentString = userAgentString;
                value.HostingFlags    = hostingFlags;
                Uri uri = new UriBuilder(path).Uri;
                value.ActivationUri.Value = uri;
                PresentationAppDomainManager.ActivationUri = uri;
                BrowserInteropHelper.SetBrowserHosted(true);
                if ((hostingFlags & HostingFlags.hfInDebugMode) != (HostingFlags)0)
                {
                    this._browserCallbackServices.ChangeDownloadState(false);
                    this._browserCallbackServices.UpdateProgress(-1L, 0L);
                    this.EnableErrorPage();
                    this._appProxyInternal = new ApplicationLauncherXappDebug(path, debugSecurityZoneURL).Initialize();
                }
                else
                {
                    switch (mime)
                    {
                    case MimeType.Document:
                        this._appProxyInternal = this.CreateAppDomainForXpsDocument();
                        if (this._appProxyInternal == null)
                        {
                            num = -1;
                        }
                        else if (streamContainer != null)
                        {
                            IntPtr iunknownForObject = Marshal.GetIUnknownForObject(streamContainer);
                            this._appProxyInternal.StreamContainer = iunknownForObject;
                            Marshal.Release(iunknownForObject);
                        }
                        this._initData.Value = null;
                        break;

                    case MimeType.Application:
                    {
                        XappLauncherApp xappLauncherApp = new XappLauncherApp(uri, applicationId, this._browserCallbackServices, new DocObjHost.ApplicationRunnerCallback(this.RunApplication), nativeProgressPage, progressAssemblyName, progressClassName, errorAssemblyName, errorClassName);
                        value.HandleHistoryLoad = false;
                        this._appProxyInternal  = new ApplicationProxyInternal();
                        break;
                    }

                    case MimeType.Markup:
                        this._appProxyInternal = this.CreateAppDomainForLooseXaml(uri);
                        this._initData.Value   = null;
                        break;

                    default:
                        num = -1;
                        break;
                    }
                }
                if (num != -1)
                {
                    if (mime == MimeType.Document || mime == MimeType.Markup)
                    {
                        this.EnableErrorPage();
                    }
                    if (this.IsAffectedByCtfIssue())
                    {
                        num = -1;
                        this._browserCallbackServices.ProcessUnhandledException(string.Format(CultureInfo.CurrentCulture, SR.Get("AffectedByMsCtfIssue"), new object[]
                        {
                            "http://support.microsoft.com/kb/954494"
                        }));
                    }
                    else
                    {
                        num = this._appProxyInternal.Run(value);
                    }
                }
            }
            catch (Exception ex)
            {
                num = -1;
                this._browserCallbackServices.ProcessUnhandledException(ex.ToString());
                throw;
            }
            catch
            {
                num = -1;
                this._browserCallbackServices.ProcessUnhandledException(SR.Get("NonClsActivationException"));
                throw;
            }
            finally
            {
                this.Cleanup(num);
            }
            EventTrace.EasyTraceEvent(EventTrace.Keyword.KeywordPerf | EventTrace.Keyword.KeywordHosting, EventTrace.Event.WpfHost_IBHSRunEnd, num);
            return(num);
        }
コード例 #4
0
 internal NativeProgressPageProxy(INativeProgressPage npp)
 {
     _npp = npp;
 }
コード例 #5
0
 internal XappLauncherApp(Uri deploymentManifest, string applicationId, IBrowserCallbackServices browser, DocObjHost.ApplicationRunnerCallback applicationRunner, INativeProgressPage nativeProgressPage, string progressPageAssembly, string progressPageClass, string errorPageAssembly, string errorPageClass)
 {
     this._deploymentManifest        = deploymentManifest;
     this._applicationId             = applicationId;
     this._browser                   = browser;
     this._applicationRunnerCallback = applicationRunner;
     this._fwlinkUri                 = null;
     this._requiredCLRVersion        = null;
     base.Startup              += this.XappLauncherApp_Startup;
     base.Exit                 += this.XappLauncherApp_Exit;
     base.Navigated            += this.XappLauncherApp_Navigated;
     this._nativeProgressPage   = nativeProgressPage;
     this._progressPageAssembly = progressPageAssembly;
     this._progressPageClass    = progressPageClass;
     this._errorPageAssembly    = errorPageAssembly;
     this._errorPageClass       = errorPageClass;
 }
コード例 #6
0
ファイル: DocobjHost.cs プロジェクト: sjyanxin/WPFSource
        int IBrowserHostServices.Run(
            String path,
            String fragment, 
            MimeType mime,
            String debugSecurityZoneURL, 
            String applicationId, 
            object streamContainer,
            object ucomLoadIStream, 
            HostingFlags hostingFlags,
            INativeProgressPage nativeProgressPage,
            string progressAssemblyName,
            string progressClassName, 
            string errorAssemblyName,
            string errorClassName, 
            IHostBrowser hostBrowser 
            )
        { 
            Invariant.Assert(String.IsNullOrEmpty(path) == false,  "path string should not be null or empty when Run method is called.");
            Invariant.Assert(mime != MimeType.Unknown, "Unknown mime type");

            EventTrace.EasyTraceEvent(EventTrace.Keyword.KeywordHosting | EventTrace.Keyword.KeywordPerf, EventTrace.Event.WpfHost_IBHSRunStart, "\""+path+"\"", "\""+applicationId+"\""); 

            int exitCode = 0; 
 
            try
            { 
                ApplicationProxyInternal.InitData initData = _initData.Value;
                initData.HostBrowser = hostBrowser;
                initData.Fragment = fragment;
                initData.UcomLoadIStream = ucomLoadIStream; 
                initData.HandleHistoryLoad = true;
                initData.MimeType.Value = mime; 
 
                // Dev10 821573 - Installing .NET 4.0 adds two parts to the user agent string, i.e.
                // .NET4.0C and .NET4.0E, potentially causing the user agent string to overflow its 
                // documented maximum length of MAX_PATH. While the right place to fix this is in
                // HostBrowserIE::GetUserAgentString in PresentationHostProxy, shared components
                // turn out hard to patch after the fact, so we do a spot-fix here in case we're
                // running in IE. 
                string userAgent = null;
                MS.Internal.Interop.HRESULT hr = hostBrowser.GetUserAgentString(out userAgent); // get it only once for both AppDomains 
                if (hr == MS.Internal.Interop.HRESULT.E_OUTOFMEMORY && (hostingFlags & HostingFlags.hfHostedInIEorWebOC) != 0) 
                {
                    userAgent = MS.Win32.UnsafeNativeMethods.ObtainUserAgentString(); 
                    hr = MS.Internal.Interop.HRESULT.S_OK;
                }
                hr.ThrowIfFailed();
 
                initData.UserAgentString = userAgent;
                initData.HostingFlags = hostingFlags; 
 
                Uri activationUri = new UriBuilder(path).Uri;
                initData.ActivationUri.Value = activationUri; 
                PresentationAppDomainManager.ActivationUri = activationUri;

                // We do this here so that it will be set correctly when our deployment application
                // launches. This matters because if it isn't set when the app ctor is run, then 
                // we will call Dispatcher.Run synchronously, which will make the browser
                // unresponsive. 
                BrowserInteropHelper.SetBrowserHosted(true); 

                if ((hostingFlags & HostingFlags.hfInDebugMode) != 0) 
                {
                    _browserCallbackServices.ChangeDownloadState(false); // stop waving the flag
                    _browserCallbackServices.UpdateProgress(-1, 0); // make the progress bar go away
                    EnableErrorPage(); 
                    _appProxyInternal = new ApplicationLauncherXappDebug(path, debugSecurityZoneURL).Initialize();
                } 
                else 
                {
                    switch (mime) 
                    {
                        case MimeType.Document:

                            _appProxyInternal = CreateAppDomainForXpsDocument(); 
                            if (_appProxyInternal == null)
                            { 
                                exitCode = -1; 
                            }
                            else 
                            {
                                if (streamContainer != null)
                                {
                                    IntPtr punk = Marshal.GetIUnknownForObject(streamContainer); 
                                    _appProxyInternal.StreamContainer = punk;
                                    Marshal.Release(punk); 
                                } 
                            }
                            // Free objects (after the _appProxyInternal.Run(initData) call below). 
                            // For the other MIME types, this is done in RunApplication().
                            _initData.Value = null;
                            break;
 
                        case MimeType.Markup:
                            _appProxyInternal = CreateAppDomainForLooseXaml(activationUri); 
                            _initData.Value = null; // Not needed anymore. 
                            break;
 
                        case MimeType.Application:
                            // This is a browser hosted express app scenario.
                            // Setup XappLauncherApp with default values, and instantiate
                            // ApplicationProxyInternal for this AppDomain. 
                            XappLauncherApp application = new XappLauncherApp(activationUri, applicationId,
                                _browserCallbackServices, new ApplicationRunnerCallback(RunApplication), 
                                nativeProgressPage, 
                                progressAssemblyName, progressClassName, errorAssemblyName, errorClassName);
 
                            // No need to handle history for progress app.  Remember
                            // it for the real app.
                            initData.HandleHistoryLoad = false;
 
                            _appProxyInternal = new ApplicationProxyInternal();
                            break; 
 
                        default:
                            exitCode = -1; 
                            break;
                    }
                }
                if (exitCode != -1) 
                {
                    if (mime == MimeType.Document || mime == MimeType.Markup) 
                    { 
                        //[[....], 7/27/07]
                        // Unfortunately, XPSViewer relies on the unhandled exception page to report bad XAML. 
                        // Ideally, only exceptions from the XamlReader should be caught and shown this way,
                        // in order not to hide platform bugs. But it's more than one place where XAML is
                        // loaded from the XPS package, and in more than one way. A little too much to change
                        // in SP1. 
                        // For loose XAML viewing, most exceptions likely to occur from this point on should be
                        // due to bad XAML. 
                        EnableErrorPage(); 
                    }
 
                    //[[....], 01/06/08]
                    // This mitigates TFS Dev10 451830 by showing an actionable message instead of crashing
                    // deep inside the Input code where MSCTF gets loaded and fails to do so. More info on the
                    // conditions leading to this bug and how we detect those can be found in the method used 
                    // for the check below and in the TFS bug database.
                    // See KB article http://support.microsoft.com/kb/954494 (linked in the displayed message). 
                    if (IsAffectedByCtfIssue()) 
                    {
                        exitCode = -1; 
                        _browserCallbackServices.ProcessUnhandledException(
                            String.Format(
                                CultureInfo.CurrentCulture,
                                SR.Get(SRID.AffectedByMsCtfIssue), 
                                "http://support.microsoft.com/kb/954494"
                            ) 
                        ); 
                    }
                    else 
                    {
                        exitCode = _appProxyInternal.Run(initData);
                    }
                } 
            }
            catch (Exception ex) 
            { 
                exitCode = -1;
                // The exception is re-thrown here, but it will get translated to an HRESULT by 
                // COM Interop. That's why ProcessUnhandledException() is called directly.
                // In most cases it runs a modal loop around the error page and never returns.
                _browserCallbackServices.ProcessUnhandledException(ex.ToString());
                throw; 
            }
            catch 
            { 
                // This catches non-CLS compliant exceptions.
                // Not having this clause triggers an FxCop violation. 
                exitCode = -1;
                _browserCallbackServices.ProcessUnhandledException(SR.Get(SRID.NonClsActivationException));
                throw;
            } 
            finally
            { 
                Cleanup(exitCode); 
            }
 
            EventTrace.EasyTraceEvent(EventTrace.Keyword.KeywordHosting | EventTrace.Keyword.KeywordPerf, EventTrace.Event.WpfHost_IBHSRunEnd, exitCode);

            return exitCode;
        }