1 year ago
#301252
Ibrahim Schi
Why WCF The value of OperationContext.Current is not the OperationContext value installed by this OperationContextScope Error without any code change?
This week without any code change, our legacy WCF web service started to throw "The value of OperationContext.Current is not the OperationContext value installed by this OperationContextScope" error on our API management system.
We have checked installed .net version (.net 4.5.1) and other installations. All seems OK. When we have tried to debug on local computer, we can not reproduce same error.
My related code part is below:
internal static T InvokeService<T>(this CalculatorClient client, Func<CalculatorClient, T> method)
{
if (client.ClientCredentials.UserName.UserName == null)
{
client.ClientCredentials.UserName.UserName = ConfigurationManager.AppSettings["APIMANAGEMENT_User"];
client.ClientCredentials.UserName.Password = ConfigurationManager.AppSettings["APIMANAGEMENT_Pwd"];
}
T result;
using (new OperationContextScope(client.InnerChannel))
{
string auth = "Basic " + Convert.ToBase64String(System.Text.Encoding.Default.GetBytes(ConfigurationManager.AppSettings["APIMANAGEMENT_User"] + ":" + ConfigurationManager.AppSettings["APIMANAGEMENT_Pwd"]));
HttpRequestMessageProperty requestMessage = new HttpRequestMessageProperty();
requestMessage.Headers["Authorization"] = auth;
OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = requestMessage;
result = method.Invoke(client);
}
return result;
}
Do you have any idea about why it is failing?
.net
wcf
.net-4.5
ibm-api-management
0 Answers
Your Answer