0

I am using the InPlaceHostingManager class to integrate the manifest file for some click once applications hosted in IIS, I am trying to get the version number. See code below

            try
        {
            iphm = new InPlaceHostingManager(new Uri(deployManifestUriStr), false);                
            iphm.GetManifestCompleted += new EventHandler<GetManifestCompletedEventArgs>(iphm_GetManifestCompleted);
            iphm.GetManifestAsync();
        }
        catch (UriFormatException uriEx)
        {
            this._logger.Fatal(uriEx, $"Unable to load Applicaition Versions (Invalid Uri) for uri : {deployManifestUriStr}");
        }
        catch (PlatformNotSupportedException platformEx)
        {
            this._logger.Fatal(platformEx, $"Unable to load Applicaition Versions (Platform Not Supported Exception) for uri : {deployManifestUriStr}");
        }
        catch (ArgumentException argumentEx)
        {
            this._logger.Fatal(argumentEx, $"Unable to load Applicaition Versions (Argument Exception) for uri : {deployManifestUriStr}");
        }
        catch (UnauthorizedAccessException ex)
        {
            this._logger.Fatal(ex);
            this._logger.Fatal(ex.InnerException);
            this._logger.Fatal(ex, $"Unable to load Applicaition Versions (Unauthorized Access Exception) for uri: {deployManifestUriStr}");
        }
        catch (Exception ex)
        {
            this._logger.Fatal(ex, $"Unable to load Applicaition Versions (Exception) for uri : {deployManifestUriStr}");
        }

I am getting the following error

System.UnauthorizedAccessException: Access to the path 'Deployment' is denied. at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.Directory.InternalCreateDirectory(String fullPath, String path, Object dirSecurityObj, Boolean checkHost) at System.IO.Directory.InternalCreateDirectoryHelper(String path, Boolean checkHost) at System.Deployment.Application.SubscriptionStore..ctor(String deployPath, String tempPath, ComponentStoreType storeType) at System.Deployment.Application.SubscriptionStore.get_CurrentUser() at System.Deployment.Application.DeploymentManager..ctor(Uri deploymentSource, Boolean isUpdate, Boolean isConfirmed, DownloadOptions downloadOptions, AsyncOperation optionalAsyncOp) at System.Deployment.Application.InPlaceHostingManager..ctor(Uri deploymentManifest, Boolean launchInHostProcess) at Logging.ApplicaitionVersionManifestHelper.Read(String deployManifestUriStr) in

The applicaition pool is running as network service. Does anyone know where the Deployment folder is?

Lord Darth Vader
  • 1,895
  • 1
  • 17
  • 26

2 Answers2

0

I had a look inside InPlaceHostingManager > DeploymentManager > SubscriptionStore > Get_CurrentUser (CurrentUSer) I Found the following

        public static SubscriptionStore CurrentUser
    {
        get
        {
            if (_userStore == null)
            {
                lock (_currentUserLock)
                {
                    if (_userStore == null)
                    {
                        string folderPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
                        string deployPath = Path.Combine(folderPath, "Deployment");
                        string tempPath = Path.Combine(Path.GetTempPath(), "Deployment");
                        _userStore = new SubscriptionStore(deployPath, tempPath, ComponentStoreType.UserStore);
                    }
                }
            }

            return _userStore;
        }
    }

After copying the code to some where I could debug it, I found the following.

string folderPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);

The above line returns nothing. This lead me to the following Stackoverflow Post

This change fixed it for me

Open your %WINDIR%\System32\inetsrv\config\applicationHost.config and look for <applicationPoolDefaults>. Under <processModel>, make sure you have the following attributes loadUserProfile="true" setProfileEnvironment="true"

Lord Darth Vader
  • 1,895
  • 1
  • 17
  • 26
0

You can use Process Monitor to see which is the Deployment folder. About how to use the Process Monitor you can refer to this link: Process Monitor

samwu
  • 3,857
  • 3
  • 11
  • 25