var environment = Microsoft.Dynamics.ApplicationPlatform.Environment.EnvironmentFactory::GetApplicationEnvironment(); str hostedServiceName = environment.Infrastructure.HostedServiceName;