public ActCtxHelper(string manifestFile)
        {
            this.lpCookie = this.InvalidHandleValue;
            this.hCtx     = this.InvalidHandleValue;
            StringBuilder stringBuilder = new StringBuilder(1024);

            if (UnsafeNclNativeMethods.GetModuleFileName(IntPtr.Zero, stringBuilder, stringBuilder.Capacity) == 0u)
            {
                throw new Win32Exception(Marshal.GetLastWin32Error());
            }
            string lpSource = Path.Combine(Path.GetDirectoryName(stringBuilder.ToString()), manifestFile);
            ACTCTX aCTCTX   = default(ACTCTX);

            aCTCTX.cbSize   = Marshal.SizeOf(typeof(ACTCTX));
            aCTCTX.lpSource = lpSource;
            this.hCtx       = UnsafeNclNativeMethods.CreateActCtxW(ref aCTCTX);
            if (this.hCtx == this.InvalidHandleValue)
            {
                throw new Win32Exception(Marshal.GetLastWin32Error());
            }
            if (!UnsafeNclNativeMethods.ActivateActCtx(this.hCtx, out this.lpCookie))
            {
                throw new Win32Exception(Marshal.GetLastWin32Error());
            }
        }
 public static extern IntPtr CreateActCtxW(ref ACTCTX actctx);