Found conflicts between different versions of the same dependent assembly.MVC3 -> MVC4 / EF4 -> EF5 - razor

The question is how to resolve conflicts between versions of assemblies in my project that was upgraded to MVC4 and EF5?
The problem is manifest in the fact that my controllers and models can include System.Data.Objects, but now my views.
I am using MVC 4, my project was upgraded from MVC 3.
Entity Framework is version 5.
I have a controller that is able to use objectcontext from System.Data.Objects.
My Usings:
using System.Data.Objects;
using System.Data.Entity;
When I try to include the using in the view form System.Data.Objects, I get :
CS0234: The type or namespace name 'Objects' does not exist in the namespace 'System.Data' (are you missing an assembly reference?)
I am targeting .net 4.5
My Build Displays this message:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1561,5): warning MSB3247: Found conflicts between different versions of the same dependent assembly.

You can build your solution in diagnostic mode to get more detailed information about the error.
Open the VS Options dialog (Tools > Options), navigate to the "Projects and Solutions" node and select "Build and Run". Change the MS Build project build output verbosity to Diagnostic.
Have a look here.

If you look at the build message, it states the 4.0 version of the .net framework is referenced... Is there a setting in your project file or web/app.config specifying a conflicting version of the .net framework?
Are you familiar with fuslog? you can set it up to log all assembly bindings that .net is doing while running your application. You should then be able to see detailed information on what is getting bound when. If you still can't figure it out, you can always do a binding redirect on that .dll in the web.config.
http://msdn.microsoft.com/en-us/library/eftw1fys.aspx -- binding redirects
http://msdn.microsoft.com/en-us/library/e74a18c4(v=vs.71).aspx -- fusion log viewer
Set up fusion logger and take a look at what the output is. If you don't get an answer from that, try the binding redirect (which would give you at least a temporary solution).

In the directory I was publishing to, there was a folder named aspnet_client. I moved it (instead of deleting it), republished, and it worked. I'm not sure why that folder decided to give me trouble out of the blue.

Related

Monodevelop fails to build, can't find Microsoft.DiaSymReader.Native.x86.dll'

I am trying to build a web api project using monodevelop on a mac. The thing is that after a few hiccups (explained in a question that turned out to be so messy I have just deleted) I get to the point of getting this error
/Users/myuser/git/LiveData/LiveData/CSC: Error CS0041: Unexpected error writing debug information -- 'Windows PDB writer is not available -- could not find Microsoft.DiaSymReader.Native.x86.dll' (CS0041) (LiveData)
In a windows machine the same project builds using visual studio targeting mono 4.5.
When I click on the error it tells me that /Users/myuser/git/LiveData/LiveData/CSC doesn't exist
Another thing is that in the folder structure of the solution there's a package folder (not the one inside the project) and inside this one I have a folder called Microsoft.Net.Compilers 1.3.2 that has inside another folder called "tools" that contains among other things csc.exe and the dll thta can't be found.
I have tried to install the dll directly in the project using nuget but even if it was installed the build showed me the same error
Thanks,
As for workaround for now you can just limit usage of Microsoft.Net.Compilers to Release configuration (edit *.csproj file):
<Import Project="..\packages\Microsoft.Net.Compilers.1.3.2\build\Microsoft.Net.Compilers.props" Condition="'$(Configuration)' == 'Release' And Exists('..\packages\Microsoft.Net.Compilers.1.3.2\build\Microsoft.Net.Compilers.props')" />
take a look at beginning of condition:
'$(Configuration)' == 'Release'
This way I can build and debug locally and build my project ie. in appharbor.
Building the project in release configuration should fix it!
This might not be completely related but may be helpful in some ways. Regarding the issue on 'could not find Microsoft.DiaSymReader.Native.x86.dll', have a look at this issue on GitHub: https://github.com/dotnet/cli/issues/3016
It seems like the solution is either:
Dependency to Microsoft.NETCore.Platforms needed for RID graph which
was missing. Any package which has transitive dependency on it (like
NETStandard.Library) could also make things work.
Adding dependency to "Microsoft.NETCore.Platforms": "1.0.1-" or
"NETStandard.Library":"1.5.0-" make it work.
adding Microsoft.NETCore.Platforms works as well

Using CakePHP 3.0 plugin

I'm currently building a new CakePHP app with version 3.0.0-RC1, and trying to install and use the jasig/phpCAS plugin. Using this guide, I've run the following command from the command prompt: composer require jasig/phpcas
This correctly copies the jasig/phpcas files into the vendor directory of my app, but one of the other files that the guide says should be updated (vendor/cakephp-plugins.php) doesn't even exist.
I've had a tough time accessing the plugin. I want to be able to call its static methods, and I keep getting errors of the form: Error: Class 'App\Controller\phpCAS' not found. (The exact directory in the error changes depending on where I'm calling the method from.)
I don't know if this is due to not having the cakephp-plugins.php file, or if I'm not calling the plugin correctly. It's my understanding that if the plugin is loaded I should just be able to call static methods on it like this: phpCAS::methodName()
First of all jasig/phpcas is not a CakePHP plugin. And the vendor/cakephp-plugins.php file is created by the CakePHP plugin installer, so if you don't see such a file, you seem to have either not installed any plugins yet, or you are not using a recent version of the installer, as the creation of this file has been introduced just recently.
Regarding the error about the class not being found, you are missing the leading namespace separator (\phpCAS::methodName()) to access the class in the global namespace, respectively you are missing a proper import (use phpCAS;) that would make the class available in the current namespace.
In case you are not familiar with namespaces, you may want to start with: http://php.net/namespaces

Error accessing WinRT sensors in C++ desktop application

I am trying to access the WinRT sensors from a Win32 desktop application using C++/CX as mentioned here: https://software.intel.com/en-us/articles/using-winrt-apis-from-desktop-applications
When I include the C++/CX header file it causes an error when building the Win32 project.
Exact error text: "error C1190: managed targeted code requires a '/clr' option."
Since I am not using /clr code at all, this is a confusing error.
Any suggestions? Please educate me if there is a better way to do this.
The error you are getting is because you are compiling some files without /ZW option for compiler. Since you are able compile at least some files with WinRT extensions, but not others, your project configuration is inconsistent.
The option /ZW (enable WinRT extensions) has to be configured on the level of project (and not on the level of individual files). There are two ways to ensure your settings are consistent. First method is through UI in Visual Studio -- you have to go through all platforms/configurations on the project and ensure /ZW is enabled, then got through all indivudual .cpp files, and ensure they don't override project level settings. This is tedious and error prone. The easier method is to open .vcxproj in notepad and do the following:
Add this section at the beginnig of the file, under root Project node:
<ItemDefinitionGroup>
<ClCompile>
<CompileAsWinRT>true</CompileAsWinRT>
</ClCompile>
</ItemDefinitionGroup>
Search and remove any other places where <CompileAsWinRT> is defined.

Support multiple assemblies on ASP.NET\C# projects

We're developing a ASP.NET application and having some problems with integration with a MS dll (Microsoft.AnalysisServices)?
The original project was linked to the dll which came with SQLServer2005 (Version=9.0.242.0). After migrating to SQLServer2008R2 (version=10.0.0.0) we encountered this problem:
Could not load file or assembly 'Microsoft.AnalysisServices,
Version=9.0.242.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91'
or one of its dependencies. The system cannot find the file
specified.
This is understood since we compile the project with one version and then another version is located on the server. After installing SQLServer2008R2 on the development machine the problem was fixed.
However we now have another problem that we need to support both SQLServer2005 and SQLServer2008R2 environments. I know that we can redirect the search path for the dll using a config file (that it will search for a different version that what it was compiled with), but I can't seem to find instructions how to use it for Web Application (on w3wp). We tried to use "Specific Version"=false, but since this is a "Strong Name" assembly it doesn't work as one would think.
The relevant link which I found is this:
http://social.msdn.microsoft.com/Forums/en-US/sqlanalysisservices/thread/47d0b992-3c10-4851-b2a5-9f72d2c0976e
Can someone please direct me to a link for solving this issue?
Update: I guess I didn't test it correctly since it doesn't work for other servers in SQLServer2008 R2. I guess you can't use range in the newVersion element. So the question is still opened for everyone! . Bottom line is that I know that I have version 9.0.242.0 but the customers version may be either 9.0.242.0 or 10.0.0.0. Is there a method which I can dynamically choose the correct assembly on the production server
You can hook into AppDomain.CurrentDomain.AssemblyResolve and load the assembly you want. If you return null it will look for it normally.
eg.
AppDomain.CurrentDomain.AssemblyResolve += Resolve;
private static Assembly Resolve(object source, ResolveEventArgs args)
{
if (args.Name.StartsWith("Microsoft.AnalysisServices,"))
return Assembly.LoadFile("Microsoft.AnalysisServices.dll");
return null;
}
Try adding a bindingRedirect to your web.config.

MySQL T4 Templates Error: Metadata file 'MySql.Data' could not be found

D:\Web\CityV2\App_Code\ActiveRecord.tt(0,0) : error CS0006: Compiling transformation: Metadata file 'MySql.Data' could not be found
Let me start by saying I'm using VWD 2008 Express.
These are the steps I've taken so far:
Created an entirely new project
Added references for Subsonic.Core.dll and MySql.Data.dll
Copied Active Record templates to project
Changed all <## include file="SQLServer.ttinclude" #> to <## include file="MySQL.ttinclude" #>
Copied the MySQL.ttinclude and Settings.ttinclude from the TemplateProviders folder
Updated Settings.ttinclude with my connectionstring and database information
Updated the Settings.ttinclude and created the external tool mapping as per ranomore's instructions
Attempted to build the code from the templates and received the error
I then realized that I didn't have MySql Connector "installed" on my dev box (even though I added a reference to the bin). So I proceeded to MySQL.com and downloaded the latest 6.0.4 connector msi and installed it (GAC). The error no longer appears, but neither does anything else: no new classes, no new errors, nothing [and yes, I refreshed the project after running the command ;-)].
Two things:
Am I missing a step somewhere?
Is there a way build the templates without needing MySQL installed to the GAC?
Unfortunately SubSonic 3 doesn't support VWD 2008 Express (or more specifically VWD doesn't support t4). There is a sort of workaround that ranomore came up with but it will require some work by you. See the following question for more details:
SubSonic ASP.NET MVC sample in Visual Web Developer Express
EDIT: I should have read your question properly you obviously already have the link above. Maybe worth your while downloading the trial of VS professional and seeing if you have more luck with that to see if it's worth outlaying the cash to buy it.
On a side note if you're looking to get an msdn subscription for free you should have a look into registering for the bizspark program