1

I believe I have all the interface registrations defined properly but get an exception when I call

container = builder.Build();

Exception:

'Common.RpcServer`2[Logic.Engine, Messages.Serializer]'

is not assignable to service

'Common.IRpcServer`2[[

Services.IEngine, Contracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Messages.ISerializer, Contracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]'.

I have very simple registration code for IEngine and ISerializer (one and none dependency respectively).

The RpcServer is a bit more complex but all its dependencies look to be resolving fine.

builder.Register(c => 
    new RpcServer<Engine, Serializer>(
        c.Resolve<ISubscription>(),
        c.Resolve<IService>() as Engine,
        c.Resolve<ISerializer>() as Serializer)
    ).As<IRpcServer<IService, ISerializer>>();

Is the listing of versions something I should be concerned about in the exception, or the nesting of the square braces?

RpcServer`2[Logic.Engine, Messages.Serializer]

versus

IRpcServer`2[[ Services.IEngine ],[ Messages.ISerializer ]]

Anything else I should be looking at to diagnose this?

Nick Josevski
  • 4,156
  • 3
  • 43
  • 63

1 Answers1

0

Voted to close as "too localized".

But if you find this question in an attempt to resolve your own issue I recommend tripple-checking all your interfaces and ensuring that they are supporting covariance.

Thanks to Tim Rogers for mentioning this, one interface had slipped through, along with another very localized issue in my code base.

See also:

Community
  • 1
  • 1
Nick Josevski
  • 4,156
  • 3
  • 43
  • 63