Exemplo n.º 1
0
        /// <summary>
        /// InvariantAssert
        /// </summary>
        internal static void InvariantAssert()
        {
            AssemblyProxy p = new AssemblyProxy();

#if TESTBUILD_CLR40
            p.Load(@"WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL");
#endif
#if TESTBUILD_CLR20
            p.Load(@"WindowsBase, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL");
#endif
            p.Parameters.Add(false);
            p.ParametersTypes.Add(typeof(bool));
            p.Invoke("MS.Internal.Invariant", "Assert", null);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Returns the permission set granted to the caller assembly
        /// </summary>
        /// <returns>the granted permission set</returns>
        internal static PermissionSet GetGrantSet()
        {
            // load the mscorlib
            AssemblyProxy ap = new AssemblyProxy();

            ap.Load("mscorlib, Version=1.2.3400.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, ProcessorArchitecture=Neutral");

            // get the permission set granted to this assembly
            ap.Parameters.Add(new PermissionSet(PermissionState.None));
            ap.Parameters.Add(new PermissionSet(PermissionState.None));
            ap.Invoke("System.AppDomain", "nGetGrantSet", AppDomain.CurrentDomain);
            PermissionSet pset = (PermissionSet)ap.Parameters[0];

            ap.Parameters.Clear();
            return(pset);
        }
Exemplo n.º 3
0
        public static void ShutdownApplication(Application app)
        {
            AssemblyProxy ap = new AssemblyProxy();

            //This now works because PKT and version #'s have been static for multiple releases.
#if TESTBUILD_CLR40
            ap.Load("PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL");
#endif
#if TESTBUILD_CLR20
            ap.Load("PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL");
#endif
            //This works, but only if the assembly's already loaded.
            //This turns out not to be true in our basic scenarios 1-6 (no framework loaded yet).
            //ap.Load("PresentationFramework");

            //This works in all cases.  There's just the problem of the API being deprecated.
            //Hopefully they don't remove it entirely.
            //ap.LoadWithPartialName("PresentationFramework");

            ap.Invoke("System.Windows.Application", "ShutdownImpl", app);
        }