Unity Configuration Section and WCF Services

1

I am using Unity.WCF off Codeplex I have a WCF service using Unity to register the types.

I want to put the correct information in my client WPF Application App.Config to register these types in my WCF Service so I can resolve them in my application.

Can someone help me get my syntax right?

Assume my interface is IBPService my class that implements it is BPService my assembly name is BPService and my namespace is BPService as well.

I've tried

<unity>
    <containers>
      <container>
        <register type="BPService.IBPService, BPService">
          <constructor>
            <param name="prefix">
              <value value="Injected by default unity section and container"/>
            </param>
          </constructor>
        </register>
      </container>
    </containers>
  </unity>

But When I hit the code that says section.Configure(container) I get... "The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)"

Thanks for any help David

wpf
wcf
unity-container
app-config
wcf-client
asked on Stack Overflow Feb 10, 2012 by DavieDave

1 Answer

0

You are attempting to register an interface. This cannot be done. An interface cannot be instantiated. What is required is to specify a mapping from the interface to a class which implements the interface. Your register entry should look like the following:

<register name="<Name>"
          type="<Namespace>.IImpl, <Assembly>"
          mapTo="<Namespace>.Impl, <Assembly>">
  <constructor>
    <param name="paramName" type="System.String" value="<ParamValue>" />
  </constructor>
</register>
answered on Stack Overflow Feb 11, 2012 by Steven Licht

User contributions licensed under CC BY-SA 3.0