This is constants class:
public static class Constants
{
public const string USER_ID = "conduent";
public const string PASSWORD = "593becd1-02f6-46f0-bf34-25b393ad041b";
public static readonly Uri BASE_URI = new Uri("https://staging.test-476b.com");
public static readonly Uri GET_TOKEN_URI = new Uri("api/session");
public static readonly Uri SEND_CASE_URI = new Uri("api/referral_request");
}
And this is usage
public class DanestreetHttp
{
private AuthToken authToken = null;
private readonly HttpClient httpClient = new HttpClient()
{
BaseAddress = Constants.BASE_URI
};
}
On the screen shot you can see the error, that was disappeared after I have changed BaseAddress = Constants.BASE_URI
to BaseAddress = new System.Uri("https://staging.test-476b.com")
. What is wrong with static readonly initialiazation?
Screen
PS. My current solution: BaseAddress = new Uri(Constants.BaseAddress)
The problem is that 2 or the URIs are invalid in Constants
, preventing this class to initialize property. It should work if you replace
public static readonly Uri GET_TOKEN_URI = new Uri("api/session");
public static readonly Uri SEND_CASE_URI = new Uri("api/referral_request");
with
public static readonly Uri GET_TOKEN_URI = new Uri("http://api/session");
public static readonly Uri SEND_CASE_URI = new Uri("http://api/referral_request");
(or https)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.