我在我的項目,該項目將覆蓋IDispatchMessageInspector
定義一個類,我添加相關的配置,但它不工作WCF錯誤:擴展無法加載
System.Configuration.ConfigurationErrorsException: The type 'InMotionGIT_NT.Address.Service, CustomHeaders, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' registered for extension 'customHeaders' could not be loaded. (C:\Users\jmachado\Documents\Visual Studio 2010\Projects\InMotionGIT_NT\Address Service\InMotionGIT_NT.Address.Service\bin\Debug\InMotionGIT_NT.Address.Service.dll.config line 67)
這是我打電話給我的定義擴展
<endpointBehaviors>
<behavior name="jsonBehavior">
<enableWebScript/>
<customHeaders/>
<!--<webHttp/>-->
</behavior>
</endpointBehaviors>
這是我如何定義我的自定義擴展
<behaviorExtensions>
<add name="customHeaders" type="InMotionGIT_NT.Address.Service, CustomHeaders, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"/>
</behaviorExtensions>
這裏的我定義的類,這是我的項目
[AttributeUsage(AttributeTargets.Class)]
public class CustomHeaders : IDispatchMessageInspector
{
public object AfterReceiveRequest(ref Message request, ClientChannel channel, InstanceContext instanceContext)
{
if ((WebOperationContext.Current.IncomingRequest.Method == "GET"))
{
WebOperationContext.Current.OutgoingResponse.Headers.Add("Access-Control-Allow-Origin", "*");
WebOperationContext.Current.OutgoingResponse.Headers.Add("Access-Control-Allow-Methods", "POST");
WebOperationContext.Current.OutgoingResponse.Headers.Add("Access-Control-Allow-Headers", "Content-Type, Accept");
}
return null;
}
public void BeforeSendReply(ref Message reply, object correlationState)
{
}
}
我錯過配置中的東西嗎?