25 internal enum ApplicationState
32 internal enum ApplicationStateDisposition
36 StartingMigrated = 65537,
38 RunningFirstTime = 131074
41 private ApplicationIdentity _applicationIdentity;
47 private string[] _manifestPaths;
51 private ApplicationStateDisposition _appRunState;
53 private IActContext _actContext;
55 private const int DefaultComponentCount = 2;
73 internal string[] ManifestPaths => _manifestPaths;
75 internal string ApplicationDirectory
84 _actContext.ApplicationBasePath(0u, out
string ApplicationPath);
85 return ApplicationPath;
89 internal string DataDirectory
98 _actContext.GetApplicationStateFilesystemLocation(1u, UIntPtr.Zero, IntPtr.Zero, out
string ppszPath);
103 internal ICMS ActivationContextData
108 return ApplicationComponentManifest;
112 internal ICMS DeploymentComponentManifest
119 return (ICMS)_manifests[0];
121 return GetComponentManifest((IDefinitionIdentity)_definitionIdentities[0]);
125 internal ICMS ApplicationComponentManifest
132 return (ICMS)_manifests[_manifests.
Count - 1];
134 return GetComponentManifest((IDefinitionIdentity)_definitionIdentities[_definitionIdentities.
Count - 1]);
138 internal ApplicationStateDisposition LastApplicationStateResult => _appRunState;
140 private ActivationContext()
147 string applicationIdentityFullName = (string)info.GetValue(
"FullName", typeof(
string));
148 string[] array = (
string[])info.GetValue(
"ManifestPaths", typeof(
string[]));
151 CreateFromName(
new ApplicationIdentity(applicationIdentityFullName));
155 CreateFromNameAndManifests(
new ApplicationIdentity(applicationIdentityFullName), array);
159 internal ActivationContext(ApplicationIdentity applicationIdentity)
161 CreateFromName(applicationIdentity);
164 internal ActivationContext(ApplicationIdentity applicationIdentity,
string[] manifestPaths)
166 CreateFromNameAndManifests(applicationIdentity, manifestPaths);
169 [SecuritySafeCritical]
170 private void CreateFromName(ApplicationIdentity applicationIdentity)
172 if (applicationIdentity ==
null)
174 throw new ArgumentNullException(
"applicationIdentity");
176 _applicationIdentity = applicationIdentity;
177 IEnumDefinitionIdentity enumDefinitionIdentity = _applicationIdentity.Identity.EnumAppPath();
178 _definitionIdentities =
new ArrayList(2);
179 IDefinitionIdentity[] array =
new IDefinitionIdentity[1];
180 while (enumDefinitionIdentity.Next(1u, array) == 1)
182 _definitionIdentities.
Add(array[0]);
185 if (_definitionIdentities.
Count <= 1)
187 throw new ArgumentException(Environment.GetResourceString(
"Argument_InvalidAppId"));
189 _manifestPaths =
null;
191 _actContext = IsolationInterop.CreateActContext(_applicationIdentity.Identity);
193 _appRunState = ApplicationStateDisposition.Undefined;
196 [SecuritySafeCritical]
197 private void CreateFromNameAndManifests(ApplicationIdentity applicationIdentity,
string[] manifestPaths)
199 if (applicationIdentity ==
null)
201 throw new ArgumentNullException(
"applicationIdentity");
203 if (manifestPaths ==
null)
205 throw new ArgumentNullException(
"manifestPaths");
207 _applicationIdentity = applicationIdentity;
208 IEnumDefinitionIdentity enumDefinitionIdentity = _applicationIdentity.Identity.EnumAppPath();
210 _manifestPaths =
new string[manifestPaths.Length];
211 IDefinitionIdentity[] array =
new IDefinitionIdentity[1];
213 while (enumDefinitionIdentity.Next(1u, array) == 1)
215 ICMS iCMS = (ICMS)IsolationInterop.ParseManifest(manifestPaths[num],
null, ref IsolationInterop.IID_ICMS);
216 if (IsolationInterop.IdentityAuthority.AreDefinitionsEqual(0u, iCMS.Identity, array[0]))
218 _manifests.
Add(iCMS);
219 _manifestPaths[num] = manifestPaths[num];
223 throw new ArgumentException(Environment.GetResourceString(
"Argument_IllegalAppIdMismatch"));
225 if (num != manifestPaths.Length)
227 throw new ArgumentException(Environment.GetResourceString(
"Argument_IllegalAppId"));
230 if (_manifests.
Count <= 1)
232 throw new ArgumentException(Environment.GetResourceString(
"Argument_InvalidAppId"));
234 _definitionIdentities =
null;
237 _appRunState = ApplicationStateDisposition.Undefined;
280 internal ICMS GetComponentManifest(IDefinitionIdentity component)
282 _actContext.GetComponentManifest(0u, component, ref IsolationInterop.IID_ICMS, out
object ManifestInteface);
283 return ManifestInteface as ICMS;
286 [SecuritySafeCritical]
287 internal byte[] GetDeploymentManifestBytes()
292 FullPath = _manifestPaths[0];
296 _actContext.GetComponentManifest(0u, (IDefinitionIdentity)_definitionIdentities[0], ref IsolationInterop.IID_IManifestInformation, out
object ManifestInteface);
297 ((IManifestInformation)ManifestInteface).get_FullPath(out FullPath);
300 return ReadBytesFromFile(FullPath);
303 [SecuritySafeCritical]
304 internal byte[] GetApplicationManifestBytes()
309 FullPath = _manifestPaths[_manifests.
Count - 1];
313 _actContext.GetComponentManifest(0u, (IDefinitionIdentity)_definitionIdentities[1], ref IsolationInterop.IID_IManifestInformation, out
object ManifestInteface);
314 ((IManifestInformation)ManifestInteface).get_FullPath(out FullPath);
317 return ReadBytesFromFile(FullPath);
320 [SecuritySafeCritical]
321 internal void PrepareForExecution()
325 _actContext.PrepareForExecution(IntPtr.Zero, IntPtr.Zero);
329 [SecuritySafeCritical]
330 internal ApplicationStateDisposition SetApplicationState(ApplicationState s)
334 return ApplicationStateDisposition.Undefined;
336 _actContext.SetApplicationRunningState(0u, (uint)s, out uint ulDisposition);
337 _appRunState = (ApplicationStateDisposition)ulDisposition;
341 [SecuritySafeCritical]
342 private void Dispose(
bool fDisposing)
344 _applicationIdentity =
null;
345 _definitionIdentities =
null;
347 _manifestPaths =
null;
348 if (_actContext !=
null)
354 private static byte[] ReadBytesFromFile(
string manifestPath)
359 int num = (int)fileStream.
Length;
360 array =
new byte[num];
365 fileStream.
Read(array, 0, num);
376 if (_applicationIdentity !=
null)
378 info.AddValue(
"FullName", _applicationIdentity.FullName, typeof(
string));
380 if (_manifestPaths !=
null)
382 info.AddValue(
"ManifestPaths", _manifestPaths, typeof(
string[]));
static int ReleaseComObject(object o)
Decrements the reference count of the Runtime Callable Wrapper (RCW) associated with the specified CO...
static void SuppressFinalize(object obj)
Requests that the common language runtime not call the finalizer for the specified object.
virtual void TrimToSize()
Sets the capacity to the actual number of elements in the T:System.Collections.ArrayList.
ContextForm Form
Gets the form, or store context, for the current application.
FileMode
Specifies how the operating system should open a file.
Identifies the activation context for the current application. This class cannot be inherited.
Provides a mechanism for releasing unmanaged resources.To browse the .NET Framework source code for t...
virtual int Count
Gets the number of elements actually contained in the T:System.Collections.ArrayList.
byte [] DeploymentManifestBytes
Gets the ClickOnce deployment manifest for the current application.
ApplicationIdentity Identity
Gets the application identity for the current application.
override int Read([In] [Out] byte[] array, int offset, int count)
Reads a block of bytes from the stream and writes the data in a given buffer.
ContextForm
Indicates the context for a manifest-activated application.
Describes the source and destination of a given serialized stream, and provides an additional caller-...
static ActivationContext CreatePartialActivationContext(ApplicationIdentity identity, string[] manifestPaths)
Initializes a new instance of the T:System.ActivationContext class using the specified application id...
SeekOrigin
Specifies the position in a stream to use for seeking.
override bool CanSeek
Gets a value indicating whether the current stream supports seeking.
Provides a T:System.IO.Stream for a file, supporting both synchronous and asynchronous read and write...
byte [] ApplicationManifestBytes
Gets the ClickOnce application manifest for the current application.
void Dispose()
Releases all resources used by the T:System.ActivationContext.
Provides a collection of methods for allocating unmanaged memory, copying unmanaged memory blocks,...
Stores all the data needed to serialize or deserialize an object. This class cannot be inherited.
virtual int Add(object value)
Adds an object to the end of the T:System.Collections.ArrayList.
Controls the system garbage collector, a service that automatically reclaims unused memory.
override long Length
Gets the length in bytes of the stream.
Allows an object to control its own serialization and deserialization.
FileAccess
Defines constants for read, write, or read/write access to a file.
static ActivationContext CreatePartialActivationContext(ApplicationIdentity identity)
Initializes a new instance of the T:System.ActivationContext class using the specified application id...
Provides the ability to uniquely identify a manifest-activated application. This class cannot be inhe...
Specifies that the class can be serialized.
static string GetDirectoryName(string path)
Returns the directory information for the specified path string.
override long Seek(long offset, SeekOrigin origin)
Sets the current position of this stream to the given value.
void GetObjectData(SerializationInfo info, StreamingContext context)
Populates a T:System.Runtime.Serialization.SerializationInfo with the data needed to serialize the ta...
Performs operations on T:System.String instances that contain file or directory path information....
Implements the T:System.Collections.IList interface using an array whose size is dynamically increase...