question

EddieLascu-4350 avatar image
0 Votes"
EddieLascu-4350 asked RichardZhang-MSFT commented

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

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

windows-uwp
· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi, Which line of code was pointed to when the error occurred? Have you performed single-step debugging, at which step did the program report an error?

0 Votes 0 ·

Hi, Sorry to bother you, did you solve this problem, and is there anything else I can help you with?

0 Votes 0 ·

Hello, I haven't heard your reply these days. Do you have any questions to solve?

0 Votes 0 ·

0 Answers