Jorge Jorge - 1 year ago 189
C# Question

WCF error: extension could not be loaded

I defined a class in my project which overrides

and I added the configuration related but it's doesn't work

System.Configuration.ConfigurationErrorsException: The type 'InMotionGIT_NT.Address.Service, CustomHeaders, Version=, 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)

this is how i called my custom extension

<behavior name="jsonBehavior">

this is how i defined my custom extension

<add name="customHeaders" type="InMotionGIT_NT.Address.Service, CustomHeaders, Version=, Culture=neutral, PublicKeyToken=null"/>

Here's the class that I defined, that's inside of my project

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)

Do I miss something in the configuration?

Answer Source

Change your type definition. First is full type name (interface+class name). After coma you place name of dll holding your type. And than the rest. Like this:

    <add name="customHeaders" type="InMotionGIT_NT.Address.Service.CustomHeaders, <DLLName> , Version=, Culture=neutral, PublicKeyToken=null" />
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download