Unable to cast object of type 'HibernatingRhinos.Profiler.Appender.ProfiledDataAccess.ProfiledConnection' to type 'System.Data.SqlClient.SqlConnection'.

444 views
Skip to first unread message

Ryan

unread,
Dec 10, 2010, 6:57:51 AM12/10/10
to nhprof
I'm trying to use Entity Framework Profiler for the first time and
I've ran into this problem straight away. Using .NET 4.0, referenced
the v4.0.dll and added the initialise to the application start. The
first EF call throws the above error.

The stack trace:

[InvalidCastException: Unable to cast object of type
'HibernatingRhinos.Profiler.Appender.ProfiledDataAccess.ProfiledConnection'
to type 'System.Data.SqlClient.SqlConnection'.]
System.Data.SqlClient.SqlCommand.set_DbConnection(DbConnection
value) +31
System.Data.Common.DbCommand.set_Connection(DbConnection value) +9

System.Data.Common.Utils.CommandHelper.SetStoreProviderCommandState(EntityCommand
entityCommand, EntityTransaction entityTransaction, DbCommand
storeProviderCommand) +60

System.Data.EntityClient.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand
entityCommand, CommandBehavior behavior) +109

System.Data.Objects.Internal.ObjectQueryExecutionPlan.Execute(ObjectContext
context, ObjectParameterCollection parameterValues) +736
System.Data.Objects.ObjectQuery`1.GetResults(Nullable`1
forMergeOption) +149

System.Data.Objects.ObjectQuery`1.System.Collections.Generic.IEnumerable<T>.GetEnumerator()
+44
System.Linq.Enumerable.FirstOrDefault(IEnumerable`1 source) +182

System.Data.Objects.ELinq.ObjectQueryProvider.<GetElementFunction>b__1(IEnumerable`1
sequence) +41

System.Data.Objects.ELinq.ObjectQueryProvider.ExecuteSingle(IEnumerable`1
query, Expression queryRoot) +59

System.Data.Objects.ELinq.ObjectQueryProvider.System.Linq.IQueryProvider.Execute(Expression
expression) +150
System.Linq.Queryable.FirstOrDefault(IQueryable`1 source) +265

isnapshot.Data.EF.Repository.UserRepository.FindByUsernamePasswordWithRoles(String
username, String password)

Not sure what is going on here.

Ayende Rahien

unread,
Dec 13, 2010, 6:51:26 AM12/13/10
to nhp...@googlegroups.com
Hi,
Can you share the code that generates this error?


--
You received this message because you are subscribed to the Google Groups "nhprof" group.
To post to this group, send email to nhp...@googlegroups.com.
To unsubscribe from this group, send email to nhprof+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nhprof?hl=en.


Pz

unread,
Jan 19, 2011, 3:33:41 PM1/19/11
to nhprof
Hi, I encoutered the same error using EF with MSSQL2008 (in
silverlight WCF RIA + EF). I wasn't able to fix that.
Pz


On 13 pro 2010, 12:51, Ayende Rahien <aye...@ayende.com> wrote:
> Hi,
> Can you share the code that generates this error?
>
> > nhprof+un...@googlegroups.com<nhprof%2Bunsu...@googlegroups.com>
> > .

Ayende Rahien

unread,
Jan 20, 2011, 6:22:03 AM1/20/11
to nhp...@googlegroups.com
Hi,
I need a bit more information than that.
What is the stack trace? How are you initializing EF Prof?

To unsubscribe from this group, send email to nhprof+un...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages