// internal for test hook internal void ActivateCodePackageInternal( string activationContextId, string codePackageName, CodePackageActivationContext activationContext, NativeRuntime.IFabricRuntime fabricRuntimePointer) { this.ThrowIfDisposed(); CodePackage codePackage; try { codePackage = activationContext.GetCodePackageObject(codePackageName); } catch (KeyNotFoundException) { AppTrace.TraceSource.WriteError("FabricHostEntryPoint.ActivateCodePackageInternal", "The code package {0} to activate was not found", codePackageName); throw new ArgumentException(StringResources.Error_CodePackageNotFound); } DllHostEntryPointDescription description = codePackage.Description.EntryPoint as DllHostEntryPointDescription; if (description == null) { AppTrace.TraceSource.WriteError("FabricHostEntryPoint.ActivateCodePackageInternal", "Code package {0} does not have a FabricHostEntryPoint", codePackageName); throw new ArgumentException(StringResources.Error_FabricHostEntryPoint_No_EntryPoint_Found); } AppTrace.TraceSource.WriteNoise("FabricHostEntryPoint.ActivateCodePackageInternal", "Adding assembly resolver path: {0}", codePackage.Path); this.assemblyResolver.AddApplicationBinariesPath(codePackage.Path); var workerEntryPoints = description.HostedDlls .Where(i => i.Kind == DllHostHostedDllKind.Managed) .Select(FabricWorkerEntryPoint.CreateFromAssemblyDescription) .ToArray(); var fabricRuntime = new FabricRuntime(fabricRuntimePointer, activationContext); ActivatedCodePackage activatedCodePackage = new ActivatedCodePackage(fabricRuntime, workerEntryPoints); bool activateSucceeded = false; try { workerEntryPoints.ForEach(wep => wep.InvokeActivate(fabricRuntime, activationContext)); this.activeCodePackages[activationContextId] = activatedCodePackage; activateSucceeded = true; } finally { if (!activateSucceeded) { activatedCodePackage.Dispose(); } } }
private void Dispose(bool disposing) { if (!this.disposed) { if (this.nativeRuntime != null) { Marshal.FinalReleaseComObject(this.nativeRuntime); this.nativeRuntime = null; } if (disposing && this.codePackageActivationContext != null) { codePackageActivationContext.Dispose(); } this.nativeRuntime = null; this.disposed = true; } }
// test hook internal FabricRuntime(NativeRuntime.IFabricRuntime fabricRuntime, CodePackageActivationContext codePackageActivationContext) { this.codePackageActivationContext = codePackageActivationContext; this.nativeRuntime = fabricRuntime; }