Microsoft.Data.Services version issue while running WCF Data Services
Asked Answered
R

1

1

I am getting the following error:

Could not load file or assembly 'Microsoft.Data.Services, Version=5.6.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

But when I go and check my Packages.config:

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="2.0.1" targetFramework="net472" />
  <package id="Microsoft.Data.Edm" version="5.6.4" targetFramework="net472" />
  <package id="Microsoft.Data.OData" version="5.6.4" targetFramework="net472" />
  <package id="Microsoft.Data.Services" version="5.6.4" targetFramework="net472" />
  <package id="Microsoft.Data.Services.Client" version="5.6.4" targetFramework="net472" />
  <package id="Microsoft.OData.EntityFrameworkProvider" version="1.0.0-beta2" targetFramework="net472" />
  <package id="System.Spatial" version="5.6.4" targetFramework="net472" />
</packages>

It showing me above file, Do I need to change the version ? If yes then how I can change it? I tried through nugget it didn't work.

I checked in my C:\Program Files\Microsoft SDKs\Azure\.NET SDK\v2.9\bin\plugins\Diagnostics there are 5.6.2 version dlls are there, I replaced them with 5.6.4 but still getting the same error.

Update:

I updated below in my web.config:

<runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
            <dependentAssembly>
                <assemblyIdentity name="Microsoft.Data.Services" publicKeyToken="31bf3856ad364e35" culture="neutral" />
                <bindingRedirect oldVersion="0.0.0.0-5.6.2.0" newVersion="5.6.4.0" />
            </dependentAssembly>
        </assemblyBinding>
    </runtime>
  <system.web>
    <compilation debug="true" targetFramework="4.7.2" />
    <httpRuntime targetFramework="4.7.2" />
  </system.web>

It changes the output to:

enter image description here

Log showing me below issues:

Model1.ssdl(2,2) : error 0152: No Entity Framework provider found for the ADO.NET provider with invariant name 'System.Data.SqlClient'. Make sure the provider is registered in the 'entityFramework' section of the application config file. See http://go.microsoft.com/fwlink/?LinkId=260882 for more information.
   at System.Data.Entity.Core.Metadata.Edm.StoreItemCollection.Loader.ThrowOnNonWarningErrors()
   at System.Data.Entity.Core.Metadata.Edm.StoreItemCollection.Loader.LoadItems(IEnumerable`1 xmlReaders, IEnumerable`1 sourceFilePaths)
   at System.Data.Entity.Core.Metadata.Edm.StoreItemCollection.Loader..ctor(IEnumerable`1 xmlReaders, IEnumerable`1 sourceFilePaths, Boolean throwOnError, IDbDependencyResolver resolver)
   at System.Data.Entity.Core.Metadata.Edm.StoreItemCollection.Init(IEnumerable`1 xmlReaders, IEnumerable`1 filePaths, Boolean throwOnError, IDbDependencyResolver resolver, DbProviderManifest&amp;amp; providerManifest, DbProviderFactory&amp;amp; providerFactory, String&amp;amp; providerInvariantName, String&amp;amp; providerManifestToken, Memoizer`2&amp;amp; cachedCTypeFunction)
   at System.Data.Entity.Core.Metadata.Edm.StoreItemCollection..ctor(IEnumerable`1 xmlReaders, IEnumerable`1 filePaths)
   at System.Data.Entity.Core.Metadata.Edm.MetadataCache.LoadStoreCollection(EdmItemCollection edmItemCollection, MetadataArtifactLoader loader)
   at System.Data.Entity.Core.Metadata.Edm.MetadataCache.&amp;lt;&amp;gt;c__DisplayClass5.&amp;lt;&amp;gt;c__DisplayClass7.&amp;lt;GetMetadataWorkspace&amp;gt;b__1()
   at System.Lazy`1.CreateValue()
   at System.Lazy`1.LazyInitValue()
   at System.Lazy`1.get_Value()
   at System.Data.Entity.Core.Metadata.Edm.MetadataCache.&amp;lt;&amp;gt;c__DisplayClass5.&amp;lt;&amp;gt;c__DisplayClass7.&amp;lt;GetMetadataWorkspace&amp;gt;b__4()
   at System.Data.Entity.Core.Metadata.Edm.MetadataWorkspace.LoadAndCheckItemCollection[T](Func`1 itemCollectionLoader)
   at System.Data.Entity.Core.Metadata.Edm.MetadataWorkspace.&amp;lt;&amp;gt;c__DisplayClass16.&amp;lt;.ctor&amp;gt;b__f()
   at System.Lazy`1.CreateValue()
   at System.Lazy`1.LazyInitValue()
   at System.Lazy`1.get_Value()
   at System.Data.Entity.Core.Metadata.Edm.MetadataWorkspace.GetItemCollection(DataSpace dataSpace, Boolean required)
   at System.Data.Entity.Core.Metadata.Edm.MetadataWorkspace.GetItemCollection(DataSpace dataSpace)
   at System.Data.Entity.Core.Objects.ObjectContext.InitializeMappingViewCacheFactory(DbContext owner)
   at System.Data.Entity.Core.Objects.ObjectContext..ctor(EntityConnection connection, Boolean isConnectionConstructor, ObjectQueryExecutionPlanFactory objectQueryExecutionPlanFactory, Translator translator, ColumnMapFactory columnMapFactory)
   at System.Data.Entity.Internal.InternalConnection.CreateObjectContextFromConnectionModel()
   at System.Data.Entity.Internal.LazyInternalConnection.CreateObjectContextFromConnectionModel()
   at System.Data.Entity.Internal.LazyInternalContext.InitializeContext()
   at System.Data.Entity.Internal.InternalContext.Initialize()
   at System.Data.Entity.Internal.InternalContext.ForceOSpaceLoadingForKnownEntityTypes()
   at System.Data.Entity.DbContext.System.Data.Entity.Infrastructure.IObjectContextAdapter.get_ObjectContext()
   at lambda_method(Closure , Object )
   at System.Data.Services.Providers.DbContextHelper.GetObjectContext(Object o)
   at System.Data.Services.Caching.MetadataCache`1.TryLookup(Type serviceType, Object dataContextInstance)
   at System.Data.Services.Providers.BaseServiceProvider.LoadMetadata(Boolean skipServiceOperations)
   at System.Data.Services.Providers.EntityFrameworkDataService`1.CreateInternalProvider(Object dataSourceInstance)
   at System.Data.Services.DataService`1.CreateMetadataAndQueryProviders(IDataServiceMetadataProvider&amp;amp; metadataProviderInstance, IDataServiceQueryProvider&amp;amp; queryProviderInstance, Object&amp;amp; dataSourceInstance, Boolean&amp;amp; isInternallyCreatedProvider)
   at System.Data.Services.DataService`1.CreateProvider()
   at System.Data.Services.DataService`1.HandleRequest()
   at System.Data.Services.DataService`1.ProcessRequestForMessage(Stream messageBody)
   at SyncInvokeProcessRequestForMessage(Object , Object[] , Object[] )
   at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]&amp;amp; outputs)
   at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc&amp;amp; rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc&amp;amp; rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage41(MessageRpc&amp;amp; rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc&amp;amp; rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc&amp;amp; rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage3(MessageRpc&amp;amp; rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage2(MessageRpc&amp;amp; rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc&amp;amp; rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage1(MessageRpc&amp;amp; rpc)
   at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)</ExceptionString></Exception></TraceRecord></DataItem></TraceData></ApplicationData></E2ETraceEvent><E2ETraceEvent xmlns="http://schemas.microsoft.com/2004/06/E2ETraceEvent"><System xmlns="http://schemas.microsoft.com/2004/06/windows/eventlog/system"><EventID>262164</EventID><Type>3</Type><SubType Name="Information">0</SubType><Level>8</Level><TimeCreated SystemTime="2021-11-08T16:50:19.9963405Z" /><Source Name="System.ServiceModel" /><Correlation ActivityID="{5ffbff76-6cbf-4bb1-a528-801615bf5b77}" /><Execution ProcessName="iisexpress" ProcessID="15812" ThreadID="8" /><Channel/><Computer>UOFL20-G0QBVN2</Computer></System><ApplicationData><TraceData><DataItem><TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Information"><TraceIdentifier>https://learn.microsoft.com/dotnet/framework/wcf/diagnostics/tracing/System-ServiceModel-Channels-MessageSent</TraceIdentifier><Description>Sent a message over a channel.</Description><AppDomain>/LM/W3SVC/3/ROOT-1-132808638175161639</AppDomain><Source>System.ServiceModel.Activation.HostedHttpContext+HostedRequestHttpOutput/42188773</Source><ExtendedData xmlns="http://schemas.microsoft.com/2006/08/ServiceModel/MessageTraceRecord"><MessageProperties><Encoder>ByteStreamMessageEncoder</Encoder><AllowOutputBatching>False</AllowOutputBatching></MessageProperties><MessageHeaders></MessageHeaders></ExtendedData></TraceRecord></DataItem></TraceData></ApplicationData></E2ETraceEvent><E2ETraceEvent xmlns="http://schemas.microsoft.com/2004/06/E2ETraceEvent"><System xmlns="http://schemas.microsoft.com/2004/06/windows/eventlog/system"><EventID>131085</EventID><Type>3</Type><SubType Name="Stop">0</SubType><Level>255</Level><TimeCreated SystemTime="2021-11-08T16:50:19.9963405Z" /><Source Name="System.ServiceModel" /><Correlation ActivityID="{5ffbff76-6cbf-4bb1-a528-801615bf5b77}" /><Execution ProcessName="iisexpress" ProcessID="15812" ThreadID="8" /><Channel/><Computer>UOFL20-G0QBVN2</Computer></System><ApplicationData><TraceData><DataItem><TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Stop"><TraceIdentifier>https://learn.microsoft.com/dotnet/framework/wcf/diagnostics/tracing/System-ServiceModel-Diagno
Reinwald answered 7/11, 2021 at 17:54 Comment(0)
P
0

Error: The server encountered an error processing the request. See server logs for more details

This issue comes into picture whenever there is any issue at WCF service. So see more details about the issue, you need to includeexceptiondetailInfaults attribute to true in servicedebug tag.

<Service Behavior>
 <Behavior Name="myServiceBehavior">
  <servicedebug includeexceptiondetailinfaults="true" />
 </Behavior>
</Service Behavior>

Either you can also add class attribute to the service class.

Could not load file or assembly 'Microsoft.Data.Services, Version=5.6.2.0,Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

For this problem, first check what version of this dll you have in your output directory.Then

  • clean your solution
  • delete all obj and bin directories
  • uninstall this package from the whole solution
  • ensure to delete this file in GAC: &userprofile%.nuget\packages\microsoft.data.services - make sure to delete whole directory
  • now you can install from NuGet the required version
Pelops answered 8/11, 2021 at 5:11 Comment(3)
Did all , still the same errorReinwald
I updated my log fileReinwald
Regarding your update, maybe you can fix it by running the following command on the package manager console: PM> Install-Package EntityFrameworkPelops

© 2022 - 2024 — McMap. All rights reserved.