Error #104

144 views
Skip to first unread message

Simone

unread,
Jun 8, 2010, 8:17:29 AM6/8/10
to structuremap-users
Hello,
this code snippet:

var channel = new LnsClientChannelManager(lnsModuleConfiguration);
container.Configure(
config => config.For<ILnsClientConfig>().Use(channel.ConfigService)
);

causes the following error:

Error: 104
Source: Registry: StructureMap.Configuration.DSL.Registry,
StructureMap, Version=2.6.1.0, Culture=neutral,
PublicKeyToken=e60ad81abae3c223
Type Instance 'b7ddfda5-b86b-4cdf-bd26-b6d3877fa4cc' (Object:
Ocem.LnsClient.ServiceInterfaces.Config.ILnsClientConfig) cannot be
plugged into type
Ocem.LnsClient.ServiceInterfaces.Config.ILnsClientConfig,
LnsClientServicesLib, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null

ConfigService is a LnsClientChannelManager's property set with an
instance of an interface returned by WCF call CreateChannel(). I would
like to register it for DI to use it when instantiating new objects
that need an instance of ILnsClientConfig.

To my knowledge, it should work properly, but as you can see, it
raises an exception. What could be the problem? Is there a workaround?

Thank you in advance.

Simone

unread,
Jun 8, 2010, 10:38:33 AM6/8/10
to structuremap-users

On 8 Giu, 14:17, Simone <laserp...@gmail.com> wrote:

> To my knowledge, it should work properly, but as you can see, it
> raises an exception. What could be the problem? Is there a workaround?
>

I found a workaround, but not something I'd like to see in production
code.

class LnsClientConfigWrapper: ILnsClientConfig {
LnsClientConfigWrapper(ILnsClientConfig config) {
_config = config;
}

/// implement ILnsClientConfig's methods forwarding'em to _config

readonly ILnsClientConfig _config;
}

then:

var channel = new
LnsClientChannelManager(lnsModuleConfiguration);
container.Configure(
config => config.For<ILnsClientConfig>().Use(new
LnsClientConfigWrapper(channel.ConfigService))
);

Jeremy D. Miller

unread,
Jun 8, 2010, 10:41:35 AM6/8/10
to structure...@googlegroups.com
Are you sure that whatever is returned from channel.ConfigService can be cast to ILnsClientConfig?

You might try:


    var channel = new LnsClientChannelManager(lnsModuleConfiguration);
    container.Configure(
        config => config.For<ILnsClientConfig>().Use(() => channel.ConfigService)
    );
 
Jeremy D. Miller
The Shade Tree Developer
jeremy...@yahoo.com



From: Simone <lase...@gmail.com>
To: structuremap-users <structure...@googlegroups.com>
Sent: Tue, June 8, 2010 7:17:29 AM
Subject: [sm-users] Error #104
--
You received this message because you are subscribed to the Google Groups "structuremap-users" group.
To post to this group, send email to structure...@googlegroups.com.
To unsubscribe from this group, send email to structuremap-users+unsub...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/structuremap-users?hl=en.


Simone

unread,
Jun 8, 2010, 11:00:02 AM6/8/10
to structuremap-users

On 8 Giu, 16:41, "Jeremy D. Miller" <jeremydmil...@yahoo.com> wrote:
> Are you sure that whatever is returned from channel.ConfigService can be cast to ILnsClientConfig?
>

Absolutely, as you can see from the log they are the same. See also
the workaround I posted.

> You might try:
>
>     var channel = new LnsClientChannelManager(lnsModuleConfiguration);
>     container.Configure(
>         config =>
> config.For<ILnsClientConfig>().Use(() => channel.ConfigService)
>
> );
>

Damn, it works! :-)

Thank you, but *why* this version works?

Jeremy D. Miller

unread,
Jun 8, 2010, 11:01:35 AM6/8/10
to structure...@googlegroups.com
Go take a peek at the StructureMap code.  That 104 error is thrown by a defensive programming check.  Something about the way it does the pluggability check isn't right.

I take pull requests;)

From: Simone <lase...@gmail.com>
To: structuremap-users <structure...@googlegroups.com>
Sent: Tue, June 8, 2010 10:00:02 AM
Subject: [sm-users] Re: Error #104
Reply all
Reply to author
Forward
0 new messages