Compiled Query Enterprise Library Version Problem

Topics: General discussion
Dec 21, 2011 at 2:32 AM

Hi,

We are using CompiledQuery to try and speed up are LINQ-SQL code, but we're encountering an error everytime invoke is executed to run the CompiledQuery.

 

Below is the stack trace we got from firebug:

 

{"Message":"Could not load file or assembly \u0027Microsoft.Practices.EnterpriseLibrary.Data, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a\u0027 or one of its dependencies. The located assembly\u0027s manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)","StackTrace":"   at System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)\r\n   at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)\r\n   at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)\r\n   at System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)\r\n   at System.Reflection.Assembly.Load(String assemblyString)\r\n   at System.Data.Metadata.Edm.ObjectItemCollection.AssemblyCacheEntry.SafeLoadReferencedAssembly(String assemblyFullName)\r\n   at System.Data.Metadata.Edm.ObjectItemCollection.AssemblyCacheEntry.InternalLoadAllReferencedAssemblies(LoadingContext context)\r\n   at System.Data.Metadata.Edm.ObjectItemCollection.AssemblyCacheEntry.InternalLoadAllReferencedAssemblies(LoadingContext context)\r\n   at System.Data.Metadata.Edm.ObjectItemCollection.AssemblyCacheEntry.InternalLoadAllReferencedAssemblies(LoadingContext context)\r\n   at System.Data.Metadata.Edm.ObjectItemCollection.AssemblyCacheEntry.InternalLoadAllReferencedAssemblies(LoadingContext context)\r\n   at System.Data.Metadata.Edm.ObjectItemCollection.AssemblyCacheEntry.LoadAssemblyFromCache(Assembly assembly, Boolean loadReferencedAssemblies, Dictionary`2 knownAssemblies, Dictionary`2& typesInLoading, List`1& errors)\r\n   at System.Data.Metadata.Edm.ObjectItemCollection.LoadAssemblyFromCache(ObjectItemCollection objectItemCollection, Assembly assembly, Boolean loadReferencedAssemblies)\r\n   at System.Data.Metadata.Edm.ObjectItemCollection.LoadAllReferencedAssemblies(Assembly assembly, Boolean loadOnlyViewGenInfo)\r\n   at System.Data.Metadata.Edm.MetadataWorkspace.LoadAssemblyForType(Type type, Assembly callingAssembly)\r\n   at System.Data.Objects.CompiledQuery.Invoke[TArg0,TArg1,TResult](TArg0 arg0, TArg1 arg1)\r\n   at WebAppPortal.Services.ContactManagement.CMService.CreateQuery(List`1 filters) in D:\\ACS\\MWEQ\\Presentation\\WebAppPortal\\Services\\1\\ConctactManagement\\CMService.asmx.cs:line 906\r\n   at WebAppPortal.Services.ContactManagement.CMService.GetSummaryAndCount(List`1 filters, Int32 page, Int32 rows, String sortBy, String sortOrder) in D:\\ACS\\MWEQ\\Presentation\\WebAppPortal\\Services\\1\\ConctactManagement\\CMService.asmx.cs:line 1117\r\n   at WebAppPortal.Services.Generic.GenericService.GetSummaryAndCount(String serviceName, List`1 filters, Int32 page, Int32 rows, String sortBy, String sortOrder) in D:\\ACS\\MWEQ\\Presentation\\WebAppPortal\\Services\\Generic\\GenericService.asmx.cs:line 48","ExceptionType":"System.IO.FileLoadException"}

 

We are using EnterpriseLibrary 4.1.0.0, but for some reason, the code keeps looking for 3.1.0.0. I've also tried to remove and add the 4.1.0.0 library references again, but still getting the same problem.

 

Does any one have any ideas?

 

Thanks.

Dec 21, 2011 at 4:44 AM

It sounds like the configuration file is referencing version 3.1.  See the FAQ for more information.

--
Randy Levy
Enterprise Library support engineer
entlib.support@live.com 

Dec 21, 2011 at 5:39 AM

Hi Randy,

I checked our web.config and there are no references to 3.1 in it. Also, we never installed 3.1 before according to my colleague, only started with 4.1 so its wierd that its trying to reference on something we didn't even used before.

I checked our GAC and there are no 3.1 versions there. Also did a file search for 3.1 versions to be sure but came up with nothing.

Could the development software we're using have anything to do with this?

Right now we're using Visual Studio 2008 and .Net Framework 3.5 for development.

Dec 21, 2011 at 6:30 AM

I think you mean LINQ to Entities don't you?  Just curious if this was working and then stopped working.

I see some others have had very similar problems: http://social.msdn.microsoft.com/Forums/en-NZ/adodotnetentityframework/thread/6b7290c1-a7f2-4ada-8d34-4076b169c40c .

It looks like Entity Framework is trying to load all of the assemblies from the calling assembly.  I would double check
all references and files on disk to verify 3.1 is not referenced (perhaps in metadata classes?) or present.

Also, you could try running the Assembly Binding Log Viewer to get more information. 

--
Randy Levy
Enterprise Library support engineer
entlib.support@live.com 

Dec 21, 2011 at 11:44 PM
Edited Dec 21, 2011 at 11:44 PM
randylevy wrote:

I think you mean LINQ to Entities don't you?  Just curious if this was working and then stopped working.

Hi Randy,

Yup, its LINQ to Entities.. sorry for the confusion :D

As to whether or not our code is working, it was working fine before, but we were experiencing some slowness using the count method (and sometimes timeout in the counting) so we decided to try applying the compiled query to see if it will help speed up the operation and that's when the problem occurs.

Anyways, I'll have a look at the links you posted.

Thanks.

Dec 28, 2011 at 3:24 AM

Hi Randy,

I think I found a solution to this (although I'm not sure if it can be considered an actual solution).

I tried running our project in Visual Studio 2010, and it turns out the the CompiledQuery is executing fine without the 3.1.0.0 problem.

Not sure what part in VS2008 could be causing the problem though. But I guess it would be a better option to migrate to using the latest software.

Thanks a lot for the assistance in the issue.