0

Unity 構成をコードから Unity.config XML ファイルに移動しようとしていますが、何らかの理由で WCF サービスをコンテナーに登録できません (正直なところ、方法がわかりません)。

完全に正常に動作するコードは次のとおりです。

var httpBinding = new BasicHttpBinding();
var endpointAddress = new EndpointAddress(serverIP);
var container = new UnityContainer();
container.RegisterType<IMyService, MyServiceClient>
                        (new ContainerControlledLifetimeManager(), new InjectionConstructor(new ResolvedParameter<BasicHttpBinding>("httpBinding"),
                                new ResolvedParameter<EndpointAddress>("endpointAddress")));

Unity.configにあるものは次のとおりです。

    <typeAliases>
       <typeAlias alias="IMyService" type="MyService.IMyService,MyService" />
       <typeAlias alias="MyServiceClient" type="MyService.MyServiceClient,MyService" />
    </typeAliases>
    <containers>
       <container>
           <type name="httpBinding" type="System.ServiceModel.BasicHttpBinding, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
            <constructor>
             <param name="configurationName">
              <value value="MyService" />
             </param>
            </constructor>
           </type>        
           <type name="endpointAddress" type="System.ServiceModel.EndpointAddress, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL" />    
           <register type="IMyService" mapTo="MyServiceClient" />
       </container>
   </containers>

明らかにこれは機能しません。私が得ているエラーは次 のとおりです。タイプ名またはエイリアス IMyService を解決できませんでした。構成ファイルを確認して、このタイプ名を確認してください。

4

0 に答える 0