System.Runtime.InteropServices.COMException exception thrown with the error message "The text associated with this error code could not be found"

Eddie Lascu 11 Reputation points
2019-12-18T14:29:30.91+00:00

Hi there,

I have a UWP application sideloaded on a Windows 10 workstation. The application is using a RESTful Web API deployed on a server. The first Web Method called by the application is to log in. The application is supposed to use Windows Authentication, so the credentials of the currently logged user are marshaled to the Web API. The asynchronous call is throwing the above-mentioned exception. I have logged the URL that is hit and it looks correct. Here is my code:

         try  
         {  
            Uri uri = new Uri(_serviceUri + @"api/users");  
            Logger.Info($"Calling the Web API method asynchronously, URL = {uri.AbsoluteUri}");  
  
            var filter = new HttpBaseProtocolFilter  
            {  
               CacheControl =  
               {  
                  ReadBehavior = HttpCacheReadBehavior.NoCache,  
                  WriteBehavior = HttpCacheWriteBehavior.NoCache  
               }  
            };  
  
            using (var httpClient = new HttpClient(filter))  
            {  
               Logger.Info("Reading the Web API method's response ...");  
               HttpResponseMessage response = await httpClient.GetAsync(uri);  
  
               if (response.IsSuccessStatusCode)  
               {  
                  string userInfoAsString = await response.Content.ReadAsStringAsync();  
                  if (!string.IsNullOrEmpty(userInfoAsString))  
                  {  
                     var userLoginInfo = JsonConvert.DeserializeObject(userInfoAsString);  
  
                     if (userLoginInfo != null)  
                     {  
                        _sessionHashCode = userLoginInfo.sessionHashCode;  
                        GroupName = userLoginInfo.groupName;  
  
                        Logger.Info($"Session Hash Code = {_sessionHashCode}");  
                        Logger.Info($"Group Name = {GroupName}");  
  
                        return userLoginInfo;  
                     }  
                  }  
                  else  
                  {  
                     Logger.Info("User Login Information object was returned null...");  
                  }  
               }  
               else  
               {  
                  string errorMessage = response.ReasonPhrase;  
                  if (!string.IsNullOrEmpty(errorMessage))  
                  {  
                     LogErrorMessage(errorMessage);  
                  }  
               }  
  
               Logger.Info($"The Http Response Code returned is {response.StatusCode} ...");  
               // log the headers if required  
               var responseContent = response.Content;  
               string contentAsString = await responseContent.ReadAsStringAsync();  
               Logger.Info($"The HttpContent of the response is {contentAsString} ...");  
            }  
         }  
         catch (Exception ex)  
         {  
            LogExceptionMessage(ex, "retrieve the Session Hash Code");  
         }  

Any suggestion why this exception would be thrown? I searched online and there aren't too many references to it and the ones I found do not really address my issue.

Thanks,
Ed

Universal Windows Platform (UWP)
{count} votes