Cannot locate dll even though I put the dll in folder - c#

I add the file to the directory but it is still telling me that it cannot find the file. What am I suppose to do now to fix this error?
Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message: Could not load file or assembly 'CrystalDecisions.Web, Version=13.0.32.4286, Culture=neutral, PublicKeyToken=692fbea5521e1304' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Source Error:
Line 18:
Line 19:
Line 20:
Line 21:
Line 22:
Source File: C:\inetpub\wwwroot\POS\web.config Line: 20
Assembly Load Trace: The following information can be helpful to determine why the assembly 'CrystalDecisions.Web, Version=13.0.32.4286, Culture=neutral, PublicKeyToken=692fbea5521e1304' could not be loaded.
=== Pre-bind state information ===
LOG: DisplayName = CrystalDecisions.Web, Version=13.0.32.4286, Culture=neutral, PublicKeyToken=692fbea5521e1304
(Fully-specified)
LOG: Appbase = file:///C:/inetpub/wwwroot/POS/
LOG: Initial PrivatePath = C:\inetpub\wwwroot\POS\bin
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\inetpub\wwwroot\POS\web.config
LOG: Using host configuration file: C:\Users\okdok\Documents\IISExpress\config\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Post-policy reference: CrystalDecisions.Web, Version=13.0.32.4286, Culture=neutral, PublicKeyToken=692fbea5521e1304
LOG: Attempting download of new URL file:///C:/Users/okdok/AppData/Local/Temp/Temporary ASP.NET Files/vs/28ae311b/78674aee/CrystalDecisions.Web.DLL.
LOG: Attempting download of new URL file:///C:/Users/okdok/AppData/Local/Temp/Temporary ASP.NET Files/vs/28ae311b/78674aee/CrystalDecisions.Web/CrystalDecisions.Web.DLL.
LOG: Attempting download of new URL file:///C:/inetpub/wwwroot/POS/bin/CrystalDecisions.Web.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Revision Number
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
<assemblies>
<add assembly="CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304" />
<add assembly="CrystalDecisions.Shared, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304" />
<add assembly="CrystalDecisions.ReportSource, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304" />
<add assembly="CrystalDecisions.ReportAppServer.Controllers, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304" />
<add assembly="CrystalDecisions.ReportAppServer.DataDefModel, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304" />
<add assembly="CrystalDecisions.CrystalReports.Engine, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304" />
<add assembly="CrystalDecisions.ReportAppServer.ClientDoc, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" />
<add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
<add assembly="Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
<add assembly="Microsoft.ReportViewer.Common, Version=10.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
<add assembly="Microsoft.Build.Framework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
<add assembly="System.Management, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
<add assembly="System.Transactions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
</assemblies>
Also do you know what I should do about this error:
Could not load file or assembly 'Microsoft.ReportingServices.Interfaces' or one of its dependencies. An attempt was made to load a program with an incorrect format.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.BadImageFormatException: Could not load file or assembly 'Microsoft.ReportingServices.Interfaces' or one of its dependencies. An attempt was made to load a program with an incorrect format.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Assembly Load Trace: The following information can be helpful to determine why the assembly 'Microsoft.ReportingServices.Interfaces' could not be loaded.
=== Pre-bind state information ===
LOG: DisplayName = Microsoft.ReportingServices.Interfaces
(Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: Microsoft.ReportingServices.Interfaces | Domain ID: 2
WRN: A partial bind occurs when only part of the assembly display name is provided.
WRN: This might result in the binder loading an incorrect assembly.
WRN: It is recommended to provide a fully specified textual identity for the assembly,
WRN: that consists of the simple name, version, culture, and public key token.
WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue.
LOG: Appbase = file:///C:/inetpub/wwwroot/POS/
LOG: Initial PrivatePath = C:\inetpub\wwwroot\POS\bin
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\inetpub\wwwroot\POS\web.config
LOG: Using host configuration file: C:\Users\okdok\Documents\IISExpress\config\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Users/okdok/AppData/Local/Temp/Temporary ASP.NET Files/vs/28ae311b/78674aee/Microsoft.ReportingServices.Interfaces.DLL.
LOG: Attempting download of new URL file:///C:/Users/okdok/AppData/Local/Temp/Temporary ASP.NET Files/vs/28ae311b/78674aee/Microsoft.ReportingServices.Interfaces/Microsoft.ReportingServices.Interfaces.DLL.
LOG: Attempting download of new URL file:///C:/inetpub/wwwroot/POS/bin/Microsoft.ReportingServices.Interfaces.DLL.
ERR: Failed to complete setup of assembly (hr = 0x8007000b). Probing terminated.
Stack Trace:
[BadImageFormatException: Could not load file or assembly 'Microsoft.ReportingServices.Interfaces' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0
System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +232
System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) +113
System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +23
System.Reflection.Assembly.Load(String assemblyString) +35
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +49
[ConfigurationErrorsException: Could not load file or assembly 'Microsoft.ReportingServices.Interfaces' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +762
System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +259
System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +167
System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +238
System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies() +78
System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +334
System.Web.Compilation.BuildManager.ExecutePreAppStart() +178
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +746
[HttpException (0x80004005): Could not load file or assembly 'Microsoft.ReportingServices.Interfaces' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +552
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +122
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +737

Related

Is there any alternative for Could not load file or Assembly except doing Update-Package -Reinstall?

I am switching between 2 branches, and in one branch I have added a new package, System.Collection.Immutable. When I switch back to the other branch, I always get,
Server Error in '/' Application.
Could not load file or assembly 'System.Collections.Immutable, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.IO.FileNotFoundException: Could not load file or assembly 'System.Collections.Immutable, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Assembly Load Trace: The following information can be helpful to determine why the assembly 'System.Collections.Immutable, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' could not be loaded.
=== Pre-bind state information ===
LOG: DisplayName = System.Collections.Immutable, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
(Fully-specified)
LOG: Appbase = file:///C:/SomePath
LOG: Initial PrivatePath = C:\SomePath\bin
Calling assembly : Microsoft.CodeAnalysis.Workspaces, Version=4.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\tret\dsdsdsdsd\web.config
LOG: Using host configuration file: C:\Users\user\Documents\IISExpress\config\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Post-policy reference: System.Collections.Immutable, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
LOG: The same bind was seen before, and was failed with hr = 0x80070002.
[FileNotFoundException: Could not load file or assembly 'System.Collections.Immutable, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.]
System.ModuleHandle.ResolveMethod(RuntimeModule module, Int32 methodToken, IntPtr* typeInstArgs, Int32 typeInstCount, IntPtr* methodInstArgs, Int32 methodInstCount) +0
System.ModuleHandle.ResolveMethodHandleInternalCore(RuntimeModule module, Int32 methodToken, IntPtr[] typeInstantiationContext, Int32 typeInstCount, IntPtr[] methodInstantiationContext, Int32 methodInstCount) +162
System.ModuleHandle.ResolveMethodHandleInternal(RuntimeModule module, Int32 methodToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext) +96
System.Reflection.CustomAttributeData..ctor(RuntimeModule scope, CustomAttributeRecord caRecord) +79
System.Reflection.CustomAttributeData.GetCustomAttributes(RuntimeModule module, Int32 tkTarget) +119
System.Reflection.CustomAttributeData.GetCustomAttributesInternal(RuntimeAssembly target) +83
Owin.Loader.DefaultLoader.SearchForStartupAttribute(String friendlyName, IList`1 errors, Boolean& conflict) +226
Owin.Loader.DefaultLoader.GetDefaultConfiguration(String friendlyName, IList`1 errors) +68
Owin.Loader.DefaultLoader.LoadImplementation(String startupName, IList`1 errorDetails) +89
Owin.Loader.DefaultLoader.Load(String startupName, IList`1 errorDetails) +30
Microsoft.Owin.Host.SystemWeb.OwinBuilder.GetAppStartup() +165
Microsoft.Owin.Host.SystemWeb.OwinHttpModule.InitializeBlueprint() +37
System.Threading.LazyInitializer.EnsureInitializedCore(T& target, Boolean& initialized, Object& syncLock, Func`1 valueFactory) +139
Microsoft.Owin.Host.SystemWeb.OwinHttpModule.Init(HttpApplication context) +160
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +584
System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +168
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +277
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +369
[HttpException (0x80004005): Could not load file or assembly 'System.Collections.Immutable, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +532
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +111
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +724
And the only way I get my application back working is by running Update-Package -Reinstall which takes an hour or so.
Is there any alternative to this?

Could not load file or assembly 'EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'

I am new in ASP .NET MVC. I try to use Entity Framework, but it falls because it does not found EF. I search a solution and in another post says that I have to change the version. I did, but it was unsuccessfull.
Web.config:
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.1.2.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<connectionStrings>
<!--<add name="DefaultConnection" providerName="System.Data.SqlClient" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=aspnet-SportsStore.WebUI-20150201211232;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnet-SportsStore.WebUI-20150201211232.mdf" />-->
<!--<add name="EFDbContext" providerName="System.Data.SqlClient" connectionString="Data Source=(localDb)\v11.0;Initial Catalog=SportsStore;Integrated Security=True" />-->
<add name="EFDbContext" providerName="System.Data.SqlClient" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=aspnet-SportsStore.WebUI-20150201211232;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnet-SportsStore.WebUI-20150201211232.mdf" />
</connectionStrings>
That is error from the browser.
Server Error in '/' Application.
Could not load file or assembly 'EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.IO.FileLoadException: Could not load file or assembly 'EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Source Error:
Line 11: public class EFProductRepository : IProductsRepository
Line 12: {
Line 13: private EFDbContext context = new EFDbContext();
Line 14:
Line 15: public IQueryable<Product> Products {
Source File: c:\Users\ruben\Documents\Visual Studio 2012\Projects\SportsStore\SportsStore.Domain\Concrete\EFProductRepository.cs Line: 13
Assembly Load Trace: The following information can be helpful to determine why the assembly 'EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' could not be loaded.
=== Pre-bind state information ===
LOG: User = rubenPC\ruben
LOG: DisplayName = EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
(Fully-specified)
LOG: Appbase = file:///C:/Users/ruben/Documents/Visual Studio 2012/Projects/SportsStore/SportsStore.WebUI/
LOG: Initial PrivatePath = C:\Users\ruben\Documents\Visual Studio 2012\Projects\SportsStore\SportsStore.WebUI\bin
Calling assembly : SportsStore.Domain, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\ruben\Documents\Visual Studio 2012\Projects\SportsStore\SportsStore.WebUI\web.config
LOG: Using host configuration file: C:\Users\ruben\Documents\IISExpress\config\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
LOG: Attempting download of new URL file:///C:/Users/ruben/AppData/Local/Temp/Temporary ASP.NET Files/vs/400ee849/decd1b79/EntityFramework.DLL.
LOG: Attempting download of new URL file:///C:/Users/ruben/AppData/Local/Temp/Temporary ASP.NET Files/vs/400ee849/decd1b79/EntityFramework/EntityFramework.DLL.
LOG: Attempting download of new URL file:///C:/Users/ruben/Documents/Visual Studio 2012/Projects/SportsStore/SportsStore.WebUI/bin/EntityFramework.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Major Version
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
Stack Trace:
[FileLoadException: Could not load file or assembly 'EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]
SportsStore.Domain.Concrete.EFProductRepository..ctor() in c:\Users\ruben\Documents\Visual Studio 2012\Projects\SportsStore\SportsStore.Domain\Concrete\EFProductRepository.cs:13
DynamicInjectorf437813e479848489e7ebb4769e5ef53(Object[] ) +70
Ninject.Activation.Providers.StandardProvider.Create(IContext context) +884
Ninject.Activation.Context.ResolveInternal(Object scope) +218
Ninject.Activation.Context.Resolve() +277
Ninject.<>c__DisplayClass15.<Resolve>b__f(IBinding binding) +86
System.Linq.WhereSelectEnumerableIterator`2.MoveNext() +145
System.Linq.Enumerable.SingleOrDefault(IEnumerable`1 source) +4078797
Ninject.Planning.Targets.Target`1.GetValue(Type service, IContext parent) +169
Ninject.Planning.Targets.Target`1.ResolveWithin(IContext parent) +747
Ninject.Activation.Providers.StandardProvider.GetValue(IContext context, ITarget target) +269
Ninject.Activation.Providers.<>c__DisplayClass4.<Create>b__2(ITarget target) +69
System.Linq.WhereSelectArrayIterator`2.MoveNext() +66
System.Linq.Buffer`1..ctor(IEnumerable`1 source) +216
System.Linq.Enumerable.ToArray(IEnumerable`1 source) +77
Ninject.Activation.Providers.StandardProvider.Create(IContext context) +847
Ninject.Activation.Context.ResolveInternal(Object scope) +218
Ninject.Activation.Context.Resolve() +277
Ninject.<>c__DisplayClass15.<Resolve>b__f(IBinding binding) +86
System.Linq.WhereSelectEnumerableIterator`2.MoveNext() +145
System.Linq.Enumerable.Single(IEnumerable`1 source) +191
Ninject.ResolutionExtensions.Get(IResolutionRoot root, Type service, IParameter[] parameters) +70
SportsStore.WebUI.Infrastructure.NinjectControllerFactory.GetControllerInstance(RequestContext requestContext, Type controllerType) in c:\Users\ruben\Documents\Visual Studio 2012\Projects\SportsStore\SportsStore.WebUI\Infrastructure\NinjectControllerFactory.cs:27
System.Web.Mvc.DefaultControllerFactory.CreateController(RequestContext requestContext, String controllerName) +74
System.Web.Mvc.MvcHandler.ProcessRequestInit(HttpContextBase httpContext, IController& controller, IControllerFactory& factory) +197
System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state) +49
System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContext httpContext, AsyncCallback callback, Object state) +50
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData) +16
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +301
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.34237
And that is the code where break:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SportsStore.Domain.Abstract;
using SportsStore.Domain.Entities;
namespace SportsStore.Domain.Concrete
{
public class EFProductRepository : IProductsRepository
{
private EFDbContext context = new EFDbContext();
public IQueryable<Product> Products {
get { return context.Products; }
}
}
}
The class EFDbContext.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SportsStore.Domain.Entities;
using System.Data.Entity;
namespace SportsStore.Domain.Concrete
{
public class EFDbContext : DbContext
{
public DbSet<Product> Products { get; set; }
}
}
Open
Toos > Nuget Package Manager > Package Manager Console
then run
install-package entityframework -version 6.0.0.0

ASP.net Could not load file or assembly

I have tried looking at previous threads with none of them helping me. I am trying to get into web dev with C# asp.net (MVC5) but when trying to run the standard template website I get an error. In Chrome and IE, I have also tried creating new projects. Here are the errors I am recieving:
Could not load file or assembly 'System.Web.WebPages.Deployment, Version=2.0.0.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)
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.IO.FileLoadException: Could not load file or assembly 'System.Web.WebPages.Deployment, Version=2.0.0.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)
=== Pre-bind state information ===
LOG: DisplayName = System.Web.WebPages.Deployment, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
(Fully-specified)
LOG: Appbase = file:///c:/users/chris/documents/visual studio 2013/Projects/WebApplication3/WebApplication3/
LOG: Initial PrivatePath = c:\users\chris\documents\visual studio 2013\Projects\WebApplication3\WebApplication3\bin
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: c:\users\chris\documents\visual studio 2013\Projects\WebApplication3\WebApplication3\web.config
LOG: Using host configuration file: C:\Users\Chris\Documents\IISExpress\config\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: System.Web.WebPages.Deployment, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
LOG: Attempting download of new URL file:///C:/Users/Chris/AppData/Local/Temp/Temporary ASP.NET Files/root/710eb268/4f51e2d0/System.Web.WebPages.Deployment.DLL.
LOG: Attempting download of new URL file:///C:/Users/Chris/AppData/Local/Temp/Temporary ASP.NET Files/root/710eb268/4f51e2d0/System.Web.WebPages.Deployment/System.Web.WebPages.Deployment.DLL.
LOG: Attempting download of new URL file:///c:/users/chris/documents/visual studio 2013/Projects/WebApplication3/WebApplication3/bin/System.Web.WebPages.Deployment.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Major Version
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
Stack Trace:
[FileLoadException: Could not load file or assembly 'System.Web.WebPages.Deployment, Version=2.0.0.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)]
System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0
System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +34
System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +152
System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) +77
System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +16
System.Reflection.Assembly.Load(String assemblyString) +28
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +38
[ConfigurationErrorsException: Could not load file or assembly 'System.Web.WebPages.Deployment, Version=2.0.0.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)]
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +752
System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +57
System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +170
System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies() +91
System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +285
System.Web.Compilation.BuildManager.ExecutePreAppStart() +153
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +516
[HttpException (0x80004005): Could not load file or assembly 'System.Web.WebPages.Deployment, Version=2.0.0.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)]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9913572
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254
Re-installed and all is good now, 2 hours of my life wasted!

System.Configuration.ConfigurationErrorsException was unhandled by user code , Message=Could not load file or assembly 'System.Web

I have read the following article http://msdn.microsoft.com/en-us/library/ff650307.aspx, about how i can authenticate asp.net mvc users from multiple domains, so inside my asp.net mvc i did the following :-
I added the following to my web.config:-
<system.web>
<membership>
<providers>
<add name="TestDomain1ADMembershipProvider" type="System.Web.Security.ActiveDirectoryMembershipProvider, System.Web, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="TestDomain1ConnectionString" connectionUsername="ad-domainA.intra\it360ad.user" connectionPassword="$$$$$" />
</providers>
</membership>
&
<connectionStrings>
<add name="TestDomain1ConnectionString" connectionString="LDAP://ad-domainA.intra/CN=Users,DC=ad-domainA,DC=intra" />
and i added the following Account.controller:-
[AllowAnonymous]
public ActionResult Login(string returnUrl)
{
ViewBag.ReturnUrl = returnUrl;
return View();
}
//
// POST: /Account/Login
[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public ActionResult Login(LoginModel model, string returnUrl)
{
MembershipProvider domainProvider;
domainProvider = Membership.Providers["TestDomain1ADMembershipProvider"];
// Validate the user with the membership system.
if (domainProvider.ValidateUser(model.UserName, model.Password))
{
if (Request.QueryString["ReturnUrl"] != null)
{
FormsAuthentication.RedirectFromLoginPage(
model.UserName, false);
}
else
{
// If there is no RequestUrl query string attribute, just set
// the authentication cookie. Provide navigation on the login page
// to pages that require authentication, or user can use browser
// to navigate to protected pages.
// Set second parameter to false so cookie is not persistent
// across sessions.
FormsAuthentication.SetAuthCookie(model.UserName, false);
}
}
else
{
ModelState.AddModelError("", "The user name or password provided is incorrect.");
return View(model);
}
return RedirectToLocal(returnUrl);
}
but when i type my user name and password inside the login screen and click on enter , i got the following error:-
System.Configuration.ConfigurationErrorsException was unhandled by
user code HResult=-2146232062 Message=Could not load file or
assembly 'System.Web, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The
system cannot find the file specified.
(C:\Users\john.john\Desktop\test login\TMS\TMS\web.config line 39)
Source=System.Web BareMessage=Could not load file or assembly
'System.Web, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one
of its dependencies. The system cannot find the file specified.
Filename=C:\Users\john.john\Desktop\test login\TMS\TMS\web.config
Line=39 StackTrace:
at System.Web.Security.Membership.Initialize()
at System.Web.Security.Membership.get_Providers() InnerException: System.IO.FileNotFoundException
HResult=-2147024894
Message=Could not load file or assembly 'System.Web, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its
dependencies. The system cannot find the file specified.
Source=mscorlib
FileName=System.Web, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
FusionLog==== Pre-bind state information === LOG: User = AD-ITSERVICES\john.john LOG: DisplayName = System.Web,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a (Partial) WRN:
Partial binding information was supplied for an assembly: WRN:
Assembly Name: System.Web, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a | Domain ID: 4 WRN: A partial bind
occurs when only part of the assembly display name is provided. WRN:
This might result in the binder loading an incorrect assembly. WRN: It
is recommended to provide a fully specified textual identity for the
assembly, WRN: that consists of the simple name, version, culture, and
public key token. WRN: See whitepaper
http://go.microsoft.com/fwlink/?LinkId=109270 for more information and
common solutions to this issue. LOG: Appbase =
file:///C:/Users/john.john/Desktop/test login/TMS/TMS/ LOG: Initial
PrivatePath = C:\Users\john.john\Desktop\test login\TMS\TMS\bin
Calling assembly : (Unknown).
=== LOG: This bind starts in default load context. LOG: Using application configuration file: C:\Users\john.john\Desktop\test
login\TMS\TMS\web.config LOG: Using host configuration file:
C:\Users\john.john\Documents\IISExpress\config\aspnet.config LOG:
Using machine configuration file from
C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private,
custom, partial, or location-based assembly bind). LOG: Attempting
download of new URL
file:///C:/Users/john.john/AppData/Local/Temp/2/Temporary ASP.NET
Files/root/2fc69b03/2c0137b8/System.Web.DLL. LOG: Attempting download
of new URL file:///C:/Users/john.john/AppData/Local/Temp/2/Temporary
ASP.NET Files/root/2fc69b03/2c0137b8/System.Web/System.Web.DLL. LOG:
Attempting download of new URL file:///C:/Users/john.john/Desktop/test
login/TMS/TMS/bin/System.Web.DLL. LOG: Attempting download of new URL
file:///C:/Users/john.john/Desktop/test
login/TMS/TMS/bin/System.Web/System.Web.DLL. LOG: Attempting download
of new URL file:///C:/Users/john.john/AppData/Local/Temp/2/Temporary
ASP.NET Files/root/2fc69b03/2c0137b8/System.Web.EXE. LOG: Attempting
download of new URL
file:///C:/Users/john.john/AppData/Local/Temp/2/Temporary ASP.NET
Files/root/2fc69b03/2c0137b8/System.Web/System.Web.EXE. LOG:
Attempting download of new URL file:///C:/Users/john.john/Desktop/test
login/TMS/TMS/bin/System.Web.EXE. LOG: Attempting download of new URL
file:///C:/Users/john.john/Desktop/test
login/TMS/TMS/bin/System.Web/System.Web.EXE.
StackTrace:
at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly,
StackCrawlMarkHandle stackMark, IntPtr pPrivHostBinder, Boolean
loadTypeFromPartialName, ObjectHandleOnStack type)
at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly,
StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean
loadTypeFromPartialName)
at System.RuntimeType.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly,
StackCrawlMark& stackMark)
at System.Type.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase)
at System.Web.Compilation.BuildManager.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase)
at System.Web.Configuration.ConfigUtil.GetType(String typeName, String propertyName, ConfigurationElement configElement,
XmlNode node, Boolean checkAptcaBit, Boolean ignoreCase)
InnerException:
on the following line of code inside the Account controller:-
public ActionResult Login(LoginModel model, string returnUrl)
{MembershipProvider domainProvider;
domainProvider = Membership.Providers["TestDomain1ADMembershipProvider"];
so what is causing this error?
For this declaration of System.Web
System.Web, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
The version is also needed (4.0 right?)
Version=4.0.0.0

ApplicationHost.CreateApplicationHost: System.IO.FileNotFoundException

I'm trying to use CreateApplicationHost to render the content of an ASP webpage. The exact code is as follows:
public class LocalPageContentAppropriator {
private RemoteDomain _host;
protected RemoteDomain Host {
get {
if (_host == null) {
_host = (RemoteDomain)ApplicationHost.CreateApplicationHost(typeof(RemoteDomain), "/", SettingsFactory.Instance.WebFileRoot + "\\");
}
return _host;
}
}
public string Resolve(string page, string query) {
return Host.ProcessRequest(page, query);
}
}
public class RemoteDomain : MarshalByRefObject {
public string ProcessRequest(string page, string query) {
using (StringWriter sw = new StringWriter()) {
SimpleWorkerRequest work = new SimpleWorkerRequest(page, query, sw);
HttpRuntime.ProcessRequest(work);
return sw.ToString();
}
}
}
The path returned for SettingsFactory.Instance.WebFileRoot points to the website's physical directory. Have tried putting appending "\bin\", etc but regardless of what I try I still receive the same error, even if I intentionally enter an incorrect path.
Now, here's where it gets interesting. Fusion Logging usually returns something like this when the assembly is loaded correctly (under normal use):
Assembly manager loaded from: C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable c:\windows\microsoft.net\framework\v4.0.30319\aspnet_wp.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: User = WICKEDWE-FFB297\ASPNET
LOG: DisplayName = MyWebsite.Web, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
(Fully-specified)
LOG: Appbase = file:///C:/Projects/Clients/G/MyWebsite/Development/MasterSite/trunk/MyWebsite.Web.Site/
LOG: Initial PrivatePath = C:\Projects\Clients\G\Galderma\Emervel\Development\MasterSite\trunk\MyWebsite.Web.Site\bin
LOG: Dynamic Base = C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\3610448a\a3b3a5e7
LOG: Cache Base = NULL
LOG: AppName = Umbraco_Sandbox_98a12b84-6e7b-401f-a543-87e17c021ad5
Calling assembly : MyWebsite.Web.Site, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Projects\Clients\G\Galderma\Emervel\Development\MasterSite\trunk\MyWebsite.Web.Site\web.config
LOG: Using host configuration file: c:\windows\microsoft.net\framework\v4.0.30319\aspnet.config
LOG: Using machine configuration file from C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Binding succeeds. Returns assembly from C:\Projects\Clients\G\Galderma\Emervel\Development\MasterSite\trunk\MyWebsite.Web.Site\bin\MyWebsite.Web.dll.
LOG: Assembly is loaded in default load context.
However, the error shows a different (IMO incorrect) Appbase path:
2011-02-08 11:10:03,734 [T1] ERROR MyWebsite.Web.Site.Common.Controls.Forms.Register [L91] - Member registration.
System.IO.FileNotFoundException: Could not load file or assembly 'MyWebsite.Web, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
File name: 'MyWebsite.Web, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'
at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
at System.Reflection.Assembly.Load(String assemblyString)
at System.UnitySerializationHolder.GetRealObject(StreamingContext context)
at System.Web.Hosting.ApplicationManager.CreateInstanceInNewWorkerAppDomain(Type type, String appId, VirtualPath virtualPath, String physicalPath)
at System.Web.Hosting.ApplicationHost.CreateApplicationHost(Type hostType, String virtualDir, String physicalDir)
at MyWebsite.Web.LocalPageContentAppropriator.get_Host() in C:\Projects\Clients\G\MyWebsite\Development\MasterSite\trunk\MyWebsite.Web\LocalPageContentAppropriator.cs:line 17
at MyWebsite.Web.LocalPageContentAppropriator.Resolve(String page, String query) in C:\Projects\Clients\G\MyWebsite\Development\MasterSite\trunk\MyWebsite.Web\LocalPageContentAppropriator.cs:line 24
at MyWebsite.Model.ProfessionalMemberLogic.Create(IProfessionalMemberInput input, String completedPagePath, String activationEmailPath, String contextPath) in C:\Projects\Clients\G\MyWebsite\Development\MasterSite\trunk\MyWebsite\Model\ProfessionalMemberLogic.cs:line 66
at MyWebsite.Web.Site.Common.Controls.Forms.Register.btnRegister_Click(Object sender, EventArgs e) in C:\Projects\Clients\G\MyWebsite\Development\MasterSite\trunk\MyWebsite.Web.Site\Common\Controls\Forms\Register.ascx.cs:line 84
Assembly manager loaded from: C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable c:\windows\microsoft.net\framework\v4.0.30319\aspnet_wp.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: User = WICKEDWE-FFB297\ASPNET
LOG: DisplayName = MyWebsite.Web, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
(Fully-specified)
LOG: Appbase = file:///c:/windows/microsoft.net/framework/v4.0.30319/
LOG: Initial PrivatePath = NULL
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: No application configuration file found.
LOG: Using host configuration file: c:\windows\microsoft.net\framework\v4.0.30319\aspnet.config
LOG: Using machine configuration file from C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///c:/windows/microsoft.net/framework/v4.0.30319/MyWebsite.Web.DLL.
LOG: Attempting download of new URL file:///c:/windows/microsoft.net/framework/v4.0.30319/MyWebsite.Web/MyWebsite.Web.DLL.
LOG: Attempting download of new URL file:///c:/windows/microsoft.net/framework/v4.0.30319/MyWebsite.Web.EXE.
LOG: Attempting download of new URL file:///c:/windows/microsoft.net/framework/v4.0.30319/MyWebsite.Web/MyWebsite.Web.EXE.
Any ideas guys?
I don't now if you get your answer or not, but I'm trying exactly the same thing and had exactly the same problems.
One, and most simple, is to put your assembly inside GAC.
Two, and a little bit tricky, is to copy your assembly to the 'bin' directory inside the directory 'physicalDir' used as parameter to ApplicationHost.CreateApplicationHost method.
It is well explained here: http://www.west-wind.com/Weblog/posts/2613.aspx
The implementation of ApplicationHost.CreateApplicationHost expects to find the assembly of the specified type in one of two places: either in the Global Assembly Cache (GAC) or within the bin directory under the specified physical directory. There is no documented way to change this behavior short of reimplementing CreateApplicationHost. So depending on your project configuration and deployment scenario, you may need to install the assembly into one of these locations.
Please take a look here for more details.
Idealty, your host will be in different assembly (that you deploy under "bin" of your physical server dir).

Categories

Resources