Пример #1
0
        internal bool InitializeDeployment(IntPtr plugin, string xapPath, string culture, string uiCulture)
        {
            TerminateAndSetCulture(culture, uiCulture);

            if (plugin == IntPtr.Zero)
            {
#if NET_2_1
                Uri source_uri = UriHelper.FromNativeUri(NativeMethods.surface_get_source_location(Surface.Native));

                if (source_uri != null)
                {
                    // full uri including xap

                    // IsolatedStorage (inside mscorlib.dll) needs some information about the XAP file
                    // to initialize it's application and site directory storage. WebClient is another user of this
                    AppDomain.CurrentDomain.SetData("xap_uri", PluginHost.GetApplicationIdentity(source_uri));
                }
#else
                // This is a horrible horrible hack for android to let us hit the isostor for the demo
                AppDomain.CurrentDomain.SetData("xap_uri", Environment.GetEnvironmentVariable("XAP_URI"));
#endif
            }
            else
            {
                PluginHost.SetPluginHandle(plugin);
            }

            if (!Directory.Exists(xapPath))
            {
                ExtractXap(xapPath);
            }
            else
            {
                XapDir = xapPath;
            }

            // this is currently disabled for the 3.0 desktop profile.  we'll
            // need it to be done by unmanaged code there, on every deployment
            // switch.
#if NET_2_1
            AppDomain.CurrentDomain.SetupInformationNoCopy.ApplicationBase = XapDir;
#endif
            // called on failure - this can occur when TPE (transparent platform extensions) being loaded
            // do not match the version against which the XAP has been linked (i.e. it was updated independently)
            AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(ResolveMissingAssemblies);

            NativeMethods.deployment_set_ensure_managed_peer_callback(native, ensure_managed_peer);
            NativeMethods.deployment_set_initialization(native, true);
            try {
                ReadManifest();

                NativeMethods.deployment_set_is_loaded_from_xap(native, true);
                return(LoadAssemblies());
            }
            catch (Exception exc) {
                Console.WriteLine(exc);
                throw;
            }
            finally {
                NativeMethods.deployment_set_initialization(native, false);
            }
        }