Re: No Default Instance defined for PluginFamily System.Data.SqlClient.SqlCredential

655 views
Skip to first unread message

keitht10uk

unread,
Feb 8, 2013, 3:46:52 AM2/8/13
to structure...@googlegroups.com
Let me add some more to this. I believe this may have worked ok until I put VS 2012 sp1 on my machine. The System.Data.SqlClient.SqlCredential object that can't be resolved is something that was introduced in .net 4.5. The issue is occurring when the following is run 

var queryProcessor = ObjectFactory.GetInstance<StarSubmissionWorkQueueQueryProcessor>();

the contructor for this class looks like this 

        public StarSubmissionWorkQueueQueryProcessor(IDbConnection connection)
        {
            this._sqlConnection = connection;            
        }

the setup for structuremap is as follows:

                ForRequestedType<IDbConnection>().TheDefault.Is.OfConcreteType<SqlConnection>().WithCtorArg(
                    "connectionString").EqualTo(xproductConfig.GetSetting("StructuredTradeApprovalsConnectionString"));

There is no use of the SqlCredential object in the code base.

On Thursday, February 7, 2013 5:19:21 PM UTC, keitht10uk wrote:

I am trying to upgrade to VS2012 and hv installed Structmap 2.6.4 and I am getting an error 'No Default Instance defined for PluginFamily System.Data.SqlClient.SqlCredential'. I have tried building the existing project as .net 4 and .net 4.5. I have made no code changes. I am pretty new to Structure Map as I have inherited this code from another team. Any help to point me in the right direction would be appreciated. Error shown below:

StructureMap.StructureMapException occurred

  HResult=-2146232832

  Message=StructureMap Exception Code:  202

No Default Instance defined for PluginFamily System.Data.SqlClient.SqlCredential, System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089

  Source=StructureMap

  ErrorCode=202

  StackTrace:

       at StructureMap.BuildSession.<.ctor>b__0(Type t) in c:\BuildAgent\work\767273992e840853\src\StructureMap\BuildSession.cs:line 36

  InnerException: 


Jeremy D. Miller

unread,
Feb 8, 2013, 9:31:42 AM2/8/13
to structure...@googlegroups.com
Look at the constructor signature of SqlConnection, does it have a ctor signature that requires SqlCredential?  By default, StructureMap is going to select the greediest constructor function and once it does that, it has to be able to resolve everything that ctor needs.  You can override the constructor selection in a Registry with SelectConstructor<SqlConnection>(() => new SqlConnection( just put nulls or defaults here, it's only using the expression anyway))
 
Jeremy D. Miller
The Shade Tree Developer
jeremy...@yahoo.com



From: keitht10uk <keith...@yahoo.co.uk>
To: structure...@googlegroups.com
Sent: Fri, February 8, 2013 2:46:56 AM
Subject: [sm-users] Re: No Default Instance defined for PluginFamily System.Data.SqlClient.SqlCredential

Let me add some more to this. I believe this may have worked ok until I put VS 2012 sp1 on my machine. The System.Data.SqlClient.SqlCredential object that can't be resolved is something that was introduced in .net 4.5. The issue is occurring when the following is run 

var queryProcessor = ObjectFactory.GetInstance<StarSubmissionWorkQueueQueryProcessor>();

the contructor for this class looks like this 

        public StarSubmissionWorkQueueQueryProcessor(IDbConnection connection)
        {
            this._sqlConnection = connection;            
        }

the setup for structuremap is as follows:

                ForRequestedType<IDbConnection>().TheDefault.Is.OfConcreteType<SqlConnection>().WithCtorArg(
                    "connectionString").EqualTo(xproductConfig.GetSetting("StructuredTradeApprovalsConnectionString"));

There is no use of the SqlCredential object in the code base.

On Thursday, February 7, 2013 5:19:21 PM UTC, keitht10uk wrote:

I am trying to upgrade to VS2012 and hv installed Structmap 2.6.4 and I am getting an error 'No Default Instance defined for PluginFamily System.Data.SqlClient. SqlCredential'. I have tried building the existing project as .net 4 and .net 4.5. I have made no code changes. I am pretty new to Structure Map as I have inherited this code from another team. Any help to point me in the right direction would be appreciated. Error shown below:

StructureMap. StructureMapException occurred

  HResult=-2146232832

  Message=StructureMap Exception Code:  202

No Default Instance defined for PluginFamily System.Data.SqlClient. SqlCredential, System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken= b77a5c561934e089

  Source=StructureMap

  ErrorCode=202

  StackTrace:

       at StructureMap.BuildSession.<. ctor>b__0(Type t) in c:\BuildAgent\work\ 767273992e840853\src\ StructureMap\BuildSession.cs: line 36

  InnerException: 


--
You received this message because you are subscribed to the Google Groups "structuremap-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to structuremap-us...@googlegroups.com.
To post to this group, send email to structure...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/structuremap-users/-/Qk0h6Vl_fJ4J.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

keitht10uk

unread,
Feb 8, 2013, 11:21:17 AM2/8/13
to structure...@googlegroups.com
Thanks that has fixed the issue.


Reply all
Reply to author
Forward
0 new messages