mishrsud / mvc-mini-profiler

Automatically exported from code.google.com/p/mvc-mini-profiler
0 stars 0 forks source link

1.9.1 MiniProfilerEF.Initialize. When executing query throws exception #100

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
1.9.1 EF Throws:

"The given assembly name or codebase was invalid. (Exception from HRESULT: 
0x80131047)"

Stack trace:

"   at System.Reflection.AssemblyName.nInit(RuntimeAssembly& assembly, Boolean 
forIntrospection, Boolean raiseResolveEvent)
   at System.Reflection.AssemblyName..ctor(String assemblyName)
   at System.Data.Entity.ModelConfiguration.Utilities.DbConnectionExtensions.GetProviderInvariantName(DbConnection connection)
   at System.Data.Entity.ModelConfiguration.Utilities.DbConnectionExtensions.GetProviderInfo(DbConnection connection, DbProviderManifest& providerManifest)
   at System.Data.Entity.DbModelBuilder.Build(DbConnection providerConnection)
   at System.Data.Entity.Internal.LazyInternalContext.CreateModel(LazyInternalContext internalContext)
   at System.Data.Entity.Internal.RetryLazy`2.GetValue(TInput input)
   at System.Data.Entity.Internal.LazyInternalContext.InitializeContext()
   at System.Data.Entity.Internal.InternalContext.Initialize()
   at System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType)
   at System.Data.Entity.Internal.Linq.InternalSet`1.Initialize()
   at System.Data.Entity.Internal.Linq.InternalSet`1.get_InternalContext()
   at System.Data.Entity.Infrastructure.DbQuery`1.System.Linq.IQueryable.get_Provider()
   at System.Linq.Queryable.Where[TSource](IQueryable`1 source, Expression`1 predicate)
   at ..."

It looks to be a problem with MiniProfilerEF.Initialize:

        Type type2 = typeof (EFProfiledDbProviderFactory<>).MakeGenericType(new Type[1]
        {
          factory.GetType()
        });
 ...

row["AssemblyQualifiedName"] = (object) type2.AssemblyQualifiedName;

Original issue reported on code.google.com by s...@strickland.com.au on 29 Aug 2011 at 8:55

GoogleCodeExporter commented 8 years ago
Inside DbConnectionExtensions.GetProviderInvariantName:

loops
  DbProviderFactories.GetFactoryClasses().Rows

extracts
  string str = (string) dataRow[3]; 

Which is: 
"MvcMiniProfiler.Data.EFProfiledDbProviderFactory`1[[System.Data.SqlClient.SqlCl
ientFactory, System.Data, Version=4.0.0.0, Culture=neutral, 
PublicKeyToken=b77a5c561934e089]], MvcMiniProfiler.EntityFramework, 
Version=1.9.1.0, Culture=neutral, PublicKeyToken=b44f9351044011a3"

create AssemblyName instance:
  AssemblyName assemblyName2 = new AssemblyName(str.Substring(str.IndexOf(',') + 1).Trim());

substring at first index of ',' + 1 is:

"System.Data, Version=4.0.0.0, Culture=neutral, 
PublicKeyToken=b77a5c561934e089]], MvcMiniProfiler.EntityFramework, 
Version=1.9.1.0, Culture=neutral, PublicKeyToken=b44f9351044011a3"

Esplode!

Original comment by s...@strickland.com.au on 29 Aug 2011 at 9:25

GoogleCodeExporter commented 8 years ago
we should probably just skip intercepting bodge interceptions, that would be 
pretty easy 

Original comment by sam.saff...@gmail.com on 29 Aug 2011 at 12:25

GoogleCodeExporter commented 8 years ago
can I confirm you removed the miniprofiler stuff from web.config? 

Original comment by sam.saff...@gmail.com on 29 Aug 2011 at 10:49

GoogleCodeExporter commented 8 years ago
Yes no mention of mini at all in the config. Restarted the host etc. 

I tweaked the factory registration table string, which made it go further, then 
hit a few more roadblocks before stopping for the evening.

Original comment by s...@strickland.com.au on 29 Aug 2011 at 11:10

GoogleCodeExporter commented 8 years ago
I have an exact repro:

http://weblogs.asp.net/fbouma/archive/2011/07/28/entity-framework-v4-1-update-1-
the-kill-the-tool-eco-system-version.aspx

http://ayende.com/blog/75777/entity-framework-4-1-update-1-backward-compatibilit
y-and-microsoft

This happens when with EF version  v4.1.10715.0 and up 

I have no idea how to fix this, patch welcome, but as we do not use EF I can 
not really afford to work through Ayende and Hans's workarounds 

Original comment by sam.saff...@gmail.com on 31 Aug 2011 at 10:41

GoogleCodeExporter commented 8 years ago
I've sent a pull request for this issue, this adds a temporary 
MiniProfilerEF.Initialize method.

Note, this looks to be fixed as part of 4.2 beta 1:
http://blogs.msdn.com/b/adonet/archive/2011/08/11/next-ef-release-plans.aspx

Original comment by m...@developer.geek.nz on 24 Sep 2011 at 7:41

GoogleCodeExporter commented 8 years ago
Temporary workaround is in latest code for SqlClient, Ole and Odbc.

Oracle and SqlCE clients will still have this issue.

To use, call MiniProfilerEF.Initialize_EF42() instead of 
MiniProfilerEF.Initialize()

Original comment by m...@developer.geek.nz on 26 Sep 2011 at 9:17