Skip to content
This repository has been archived by the owner on Jan 15, 2021. It is now read-only.

Glimpse.EF6 is incompatible with MiniProfiler.EF6 #902

Closed
ktmaul opened this issue May 21, 2015 · 8 comments
Closed

Glimpse.EF6 is incompatible with MiniProfiler.EF6 #902

ktmaul opened this issue May 21, 2015 · 8 comments

Comments

@ktmaul
Copy link

ktmaul commented May 21, 2015

When attempting to use Glimpse.EF6 at the same time as MiniProfiler.EF6, I receive the following error:

Unable to define EFProfiledDbProviderServices class of type 'GlimpseDbProviderServices'. Please check that your web.config defines a section underneath <system.data>

It seems that there is an attempt by the EFProfiledDbProvider to retrieve a singleton defined as the static "Instance" field or property by each DbProviderService implementation. This pattern seems to be followed by both SqlServerProviderServices and SqlCeProviderServices.

Platform: ASP.NET 4.5 WebForms on IIS Express (and IIS 7.0)
Packages Installed: Glimpse 1.8.6, Glimpse.AspNet 1.9.2, Glimpse.WebForms 1.1.1, Glimpse.Ado 1.7.3, Glimpse.EF6 1.6.5

Stack Trace:

[Exception: Unable to define EFProfiledDbProviderServices class of type 'GlimpseDbProviderServices'. Please check that your web.config defines a section underneath <system.data>.]
StackExchange.Profiling.Data.EFProfiledDbProviderServices1..ctor() in d:\Files\GitHub\miniprofiler\dotnet\StackExchange.Profiling.EntityFramework6\EFProfiledDbProviderServices.cs:52 StackExchange.Profiling.Data.EFProfiledDbProviderServices1..cctor() in d:\Files\GitHub\miniprofiler\dotnet\StackExchange.Profiling.EntityFramework6\EFProfiledDbProviderServices.cs:24

[TypeInitializationException: The type initializer for 'StackExchange.Profiling.Data.EFProfiledDbProviderServices`1' threw an exception.]

[TargetInvocationException: Exception has been thrown by the target of an invocation.]
System.RuntimeFieldHandle.GetValue(RtFieldInfo field, Object instance, RuntimeType fieldType, RuntimeType declaringType, Boolean& domainInitialized) +0
System.Reflection.RtFieldInfo.UnsafeGetValue(Object obj) +124
System.Reflection.RtFieldInfo.InternalGetValue(Object obj, StackCrawlMark& stackMark) +132
System.Reflection.RtFieldInfo.GetValue(Object obj) +21
StackExchange.Profiling.EntityFramework6.MiniProfilerEF6.WrapProviderService(DbProviderServices services) in d:\Files\GitHub\miniprofiler\dotnet\StackExchange.Profiling.EntityFramework6\MiniProfilerEF6.cs:78
StackExchange.Profiling.EntityFramework6.MiniProfilerEF6.b__1(DbProviderServices services, Object o) in d:\Files\GitHub\miniprofiler\dotnet\StackExchange.Profiling.EntityFramework6\MiniProfilerEF6.cs:31
System.Data.Entity.Infrastructure.DependencyResolution.WrappingDependencyResolver1.GetService(Type type, Object key) +202 System.Data.Entity.Infrastructure.DependencyResolution.<>c__DisplayClass3.<GetService>b__0(IDbDependencyResolver r) +60 System.Linq.WhereSelectArrayIterator2.MoveNext() +66
System.Linq.Enumerable.FirstOrDefault(IEnumerable1 source, Func2 predicate) +94
System.Data.Entity.Infrastructure.DependencyResolution.ResolverChain.GetService(Type type, Object key) +250
System.Data.Entity.Infrastructure.DependencyResolution.CompositeResolver2.GetService(Type type, Object key) +63 System.Data.Entity.Infrastructure.DependencyResolution.DbDependencyResolverExtensions.GetService(IDbDependencyResolver resolver, Object key) +145 System.Data.Entity.Utilities.DbProviderFactoryExtensions.GetProviderServices(DbProviderFactory factory) +174 System.Data.Entity.Core.Common.DbProviderServices.GetProviderServices(DbConnection connection) +50 System.Data.Entity.Infrastructure.<>c__DisplayClass1.<ResolveManifestToken>b__0(Tuple3 k) +45
System.Collections.Concurrent.ConcurrentDictionary2.GetOrAdd(TKey key, Func2 valueFactory) +72
System.Data.Entity.Infrastructure.DefaultManifestTokenResolver.ResolveManifestToken(DbConnection connection) +360
System.Data.Entity.Utilities.DbConnectionExtensions.GetProviderInfo(DbConnection connection, DbProviderManifest& providerManifest) +89
System.Data.Entity.DbModelBuilder.Build(DbConnection providerConnection) +79
System.Data.Entity.Internal.LazyInternalContext.CreateModel(LazyInternalContext internalContext) +143
System.Data.Entity.Internal.RetryLazy2.GetValue(TInput input) +171 System.Data.Entity.Internal.LazyInternalContext.InitializeContext() +594 System.Data.Entity.Internal.InternalContext.Initialize() +31 System.Data.Entity.Internal.InternalContext.ForceOSpaceLoadingForKnownEntityTypes() +79 System.Data.Entity.DbContext.System.Data.Entity.Infrastructure.IObjectContextAdapter.get_ObjectContext() +58 Microsoft.AspNet.DynamicData.ModelProviders.<>c__DisplayClass6.<.ctor>b__0() +82 Microsoft.AspNet.DynamicData.ModelProviders.EFDataModelProvider..ctor(Func1 dbContextFactory) +390
WebApp.DynamicDataConfig.RegisterRoutes(RouteCollection routes) in c:\Data\kturney_precW7Uw3\Precision\Framework\Shell\1.0\WebApp\App_Start\DynamicDataConfig.cs:19
WebApp.Global.Application_Start(Object sender, EventArgs e) in c:\Data\kturney_precW7Uw3\Precision\Framework\Shell\1.0\WebApp\Global.asax.cs:35

[HttpException (0x80004005): Exception has been thrown by the target of an invocation.]
System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +9936485
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +118
System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +172
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +336
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +296

[HttpException (0x80004005): Exception has been thrown by the target of an invocation.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9950728
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254

@avanderhoorn
Copy link
Member

Looks like this should be a one line fix, any interest in sending in a PR?

@ktmaul
Copy link
Author

ktmaul commented May 21, 2015

Absolutely. I'll send one later today.

@avanderhoorn
Copy link
Member

Great!

On 21 May 2015 at 08:36, Kyle notifications@github.com wrote:

Absolutely. I'll send one later today.


Reply to this email directly or view it on GitHub
#902 (comment).

@ktmaul
Copy link
Author

ktmaul commented May 23, 2015

Even with the singleton, the EFProfiledDbProviderServices throws an error regarding the GlimpseDbCommand not being cloneable. I tried making the command ICloneable, but I keep receiving the same error.

It might not be possible to fix this issue without coordinating with the MiniProfiler team. Maybe an extensible ProfilingDbProviderServices package shared between the two projects would work.

@avanderhoorn
Copy link
Member

Pity that just adding the singleton didn't work. Were you able to see why the cloneable code was complaining, as in what the exception was?

@ktmaul
Copy link
Author

ktmaul commented May 28, 2015

I received the following message:

Underlying GlimpseDbCommand is not cloneable

Which only occurs after the EFProfiledDbProviderServices attempts to unbox a DbCommand as ICloneable. I thought that it was weird that the issue persisted after I made GlimpseDbCommand implement ICloneable.

@avanderhoorn
Copy link
Member

@ktmaul Do you have a code reference to where specifically in the code base that unboxing happens?

@RudeySH
Copy link

RudeySH commented Feb 9, 2017

Why was this closed? This still seems to be the case. I got the same error as @ktmaul, which does not reappear when I comment out MiniProfilerEF6.Initialize();.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants