MVVMLight installs one version of assembly, but references different version - mvvm-light

MVVMLight 4.3.31.28629 in WPF project, VS2013.
The MVVMLight install (via nuget) added Microsoft.Practices.ServiceLocation 1.2.0.0.
Inspecting MvvmLight.Extras.WPF4, I find this:
My application runs in the debugger, but not when launched from the command line. (It throws an exception from the ViewModelLocator ctor, trying to find Microsoft.Practices.ServiceLocation 1.0.0.0.)
Why does it run inside the debugger, and how do I fix it to run outside the debugger?
Thanks --
UPDATE
What the hell? Why are two versions of the same assembly referenced?
at ProdoMetro.ViewModel.ViewModelLocator..ctor()
InnerException: System.IO.FileLoadException
HResult=-2146234304
Message=Could not load file or assembly **Microsoft.Practices.ServiceLocation, Version=1.2.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)
Source=TimerDoro
FileName=Microsoft.Practices.ServiceLocation, Version=1.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
FusionLog=""
StackTrace:
at ProdoMetro.ViewModel.ViewModelLocator..cctor()
InnerException: System.IO.FileLoadException
HResult=-2146234304
Message=Could not load file or assembly **Microsoft.Practices.ServiceLocation, Version=1.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)
FileName=Microsoft.Practices.ServiceLocation, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
FusionLog==== Pre-bind state information ===
LOG: DisplayName = Microsoft.Practices.ServiceLocation, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
(Fully-specified)

Related

Why is System.Net.Http.Formatting trying to load Newtonsoft.Json (6.0.0.0) using .NET 4.8

I have .NET 4.8 ASP.NET project that throws a "binding" error while at runtime.
Could not load file or assembly 'Newtonsoft.Json, Version=6.0.0.0,
Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its
dependencies. The located assembly's manifest definition does not
match the assembly reference.
I've triple checked NuGet and binding information in the project files.
I turned on Assembly Binding.
LOG: DisplayName = Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed
(Fully-specified) LOG: Appbase =
PrivatePath = F:\inetpub...
Calling assembly : System.Net.Http.Formatting, Version=5.2.8.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35.
Why is System.Net.Http.Formatting trying to load Newtonsoft.Json (6.0.0.0) using .NET 4.8

Using Cloud SQL with .NET Bookshelf tutorial

I'm following the bookshelf tutorial with cloud sql:
https://cloud.google.com/dotnet/getting-started/using-cloud-sql
When running the application on my localmachine the application works fine.
When the application is deployed to Compute Engine. The server shows a runtime error which can't be read.
<customErrors mode="Off"/>
doesn't help to show the error.
When connecting thru RDP and watching the application on localhost on the Remote Desktop the following error is shown:
Server Error in '/' Application.
Could not load file or assembly 'System.Web.WebPages.Razor, 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.Razor, 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)
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.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' could not be loaded.
WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
Stack Trace:
[FileLoadException: Could not load file or assembly 'System.Web.WebPages.Razor, 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)]
WebMatrix.WebData.PreApplicationStartCode.Start() +0
[InvalidOperationException: The pre-application start initialization method Start on type WebMatrix.WebData.PreApplicationStartCode threw an exception with the following error message: Could not load file or assembly 'System.Web.WebPages.Razor, 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.Compilation.BuildManager.InvokePreStartInitMethodsCore(ICollection`1 methods, Func`1 setHostingEnvironmentCultures) +874
System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection`1 methods) +169
System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +133
System.Web.Compilation.BuildManager.ExecutePreAppStart() +176
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +734
[HttpException (0x80004005): The pre-application start initialization method Start on type WebMatrix.WebData.PreApplicationStartCode threw an exception with the following error message: Could not load file or assembly 'System.Web.WebPages.Razor, 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) +579
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +112
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +712
I can't declare why the application gives this error since I haven't found some kind of reference in the project to the 2.0.0.0 version of Razor.
Version 3.0.0.0 of System.Web.WebPages.Razor is included as project reference.
Is it wise to downgrade to version 2 of Razor or are there other solutions?
So, there's a dependency to 2.0 version but you have 3.0 version installed on your system? In that case, you can try declaring a binding redirect from 2.0 to 3.0. Here's more information on how to declare binding redirects:
https://msdn.microsoft.com/en-us/library/7wd6ex19(v=vs.110).aspx
The total solution to solve the problem is:
Declare binding redirects https://stackoverflow.com/a/39999353/2629901 as answered by #Mete Atamel on this post
After declaring binding redirects to following error is shown:
Attempt by security transparent method 'WebMatrix.WebData.PreApplicationStartCode.Start()' to access security critical method 'System.Web.WebPages.Razor.WebPageRazorHost.AddGlobalImport(System.String)' failed.
This can be solved by
Install-Package Microsoft.AspNet.WebHelpers with NuGet Console as mentioned in https://stackoverflow.com/a/19568376/2629901
After that the following error is shown
Could not load file or assembly 'WebMatrix.Data, Version=3.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)
This can be solved by
Install-Package Microsoft.AspNet.WebPages.Data with NuGet Console as mentioned in https://stackoverflow.com/a/22587521/2629901

Unable to find reference to assembly in a Visual Studio website

I have a legacy WebSite project (as opposed to a Web Application project). It was using .net 3.5 but I am updating it to 4.0.
Due to the compilation error ...
Compiler Error Message: CS1705: Assembly 'System.Web.Mvc, Version=4.0.0.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35' uses 'System.Web.WebPages,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' which has
a higher version than referenced assembly 'System.Web.WebPages,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
... I added a reference to the newer version of System.Web.WebPages. This added the following line to the web.config file:
<add assembly="System.Web.WebPages, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
However, when I try to build the website I get this error:
The type 'System.Web.WebPages.WebPage' exists in both
c:\Windows\Microsoft.NET\assembly\GAC_MSIL\System.Web.WebPages\v4.0_2.0.0.0__31bf3856ad364e35\System.Web.WebPages.dll'
and 'c:\Windows\Microsoft.NET\assembly\GAC_MSIL\System.Web.WebPages\v4.0_1.0.0.0__31bf3856ad364e35\System.Web.WebPages.dll'
I cannot seem to find a reference anywhere in the project to the v4.0 1 version of WebPages. I assume this means that some other assembly is probably referring to it but I'm not sure where to go from here.
Any idea how to track down what is referring to the assembly and either remove the reference or update the calling the assembly?

system.web.extension problem

THIS is the error i am getting when i am compiling my project
Parser Error Message: Could not load file or assembly 'System.Web.Abstractions,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its
dependencies. The system cannot find the file specified
Source File: C:\Documents and Settings\Administrator\My Documents\data\Web-page adversting
impression 2\web.config Line: 25
Assembly Load Trace: The following information can be helpful to determine why the
assembly 'System.Web.Abstractions, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35' could not be loaded.
Double-check the System.Web.Abstractions DLL is set to "Copy Local = true" (right click on the properties for the reference).

ASP.3.5 Error while using Enterprise Library

I have a VisualStudio solution created in Vs2005 which is making use of Microsoft Enterprise Data Library.Now I converted this to Visual studio 2008 .Now when i buid the project ,i am getting an error like the below
An error occurred creating the configuration section handler for dataConfiguration: Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) (D:\dotnet\Test\Test.UI\web.config line 4)
My Web.Config 4 th line is as follows
<section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=3.5.0.0, Culture=neutral, PublicKeyToken=null"/>
I chanegd the version from 2.0.0.0 to 3.5.0.0 .But no result.Same error i am getting.
Can anyone help me to solve this ? Thanks in advance
Have you checked if the public key token is in fact null? You can do this with sn –T Microsoft.Practices.EnterpriseLibrary.Data.dll

Resources