Why won't this .NET project compile? - asp.net

I'm building a project as part of a course, I didn't build it from scratch but I've got it at a stable level that compiles perfectly with no errors or warnings.
I need to add Entity Framework Core. The video shows the instructor installing 2.1.4 even though the latest is 3.1.4. What the heck, I install the older version. Everything's still peachy.
But I don't want 2.1.4, I want 3.1.4. I won't go into the reasons, but suffice to say that version supports EDMX. Please don't question me on that. Incidentally I have 3 projects in the solution and only one of them had the EF Core installed. Does that matter? Anyway, after installing 3.1.4 in that one project I get this.
Error NU1107 Version conflict detected for Microsoft.EntityFrameworkCore. Install/reference Microsoft.EntityFrameworkCore 3.1.4 directly to project OdeToFood to resolve this issue.
OdeToFood -> OdeToFood.Data -> Microsoft.EntityFrameworkCore (>= 3.1.4)
OdeToFood -> Microsoft.AspNetCore.App 2.1.1 -> Microsoft.EntityFrameworkCore (>= 2.1.1 && < 2.2.0). OdeToFood D:\Visual Studio Projects\OdeToFood\OdeToFood\OdeToFood.csproj 1
OdeToFOod is the project, OdeToFood.Data is the one of three projects I added EF Core to.
Dear Microsoft, is it asking too much for you to give your error messages in something resembling English? I'm at my wits end with this stupid project. The error message SEEMS to be saying to install 3.1.4 directly to that project. Isn't that what I just did?! Perhaps they mean right-click the project and say manage Nuget for that project instead of "Manage Packages for Solution"? Doesn't make sense to me, but I'll try it. So when I do that it (obviously) already shows 3.1.4 as installed, so that can't be it. So why don't we start nice and fresh, huh? Let's uninstall 3.1.4 from that project and re-install.
Nope. Same error message except this time it mentions a different project, one that never had EF Core installed in the first place. Okay fine Microsoft, I'll play your game. So even though I have no use for it in this second project, I'll install it anyway. Let's see what happens shall we?
OMG.... DISASTER!!!! It's now worse! I still have that error message, but now I have a "package out of dependency constraint" (English please??) and it references ANOTHER package that now has a version conflict, one that hasn't even been touched. What the hell is going on here? I'll bet at this point I can't even go back to Core 2.1.4 anymore. There's got to be some config file or .csproj or something that I can edit because this is unbelievable. I'm trying to follow the directions as best as I can understand them (which isn't much) and it keeps getting worse. And not only that but it appears that EF Core never DID install on this other project anyway so I think there's no fixing this problem at this point, I'm going to have to restore from backup and start over. Why does Microsoft have to make everything so freaking complicated?! Can they at least make this a little more forgiving and user friendly so it doesn't take a PhD to figure out these errors?
I'm just a beginner at this but how am I supposed to learn this if I can't even get a simple thing like this to compile? I try to follow the directions as best I can and that only makes things worse. I'm ready to declare this project FUBAR, throw my computer through a window, buy a sheep farm and never code again!

We love Scott Allen and his tutorials :)
Seems like scoot have updated entity framework with latest version. Link below
GitHub Repository
If you want to update by yourself i suggest to remove ef Core 2.1 packages from odeToFood & OdeToFood.Data project and install ef core 3.1 in both project accordingly. Hopefully this will resolve the issue. Happy learning.

Related

.NET Framework Dependency appxmanifest

I am in process of prepping my Windows Desktop app for upload to the MS Store. I have a (fully functional) MSI installer for my app and attempted to use the Desktop App Converter (DAC) but experienced an error and have not gotten past it yet. So I decided to give manual package (appx) creation a try and it went well since I was able to install my app using the package I created. But I have a question about how to handle my .NET Framework dependency in the package. My MSI Installer has the '.NET Framework version 4.7.1' as a prerequisite so that it gets downloaded and installed (from MS, if not already installed). My question is how to handle the prerequisite in my package. I'm assuming it would go in the AppxManifest.xml under Dependencies where I currently have (note I removed the brackets so my code would display here)...
Dependencies
TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.14316.0" MaxVersionTested="10.0.16299.309" /
/Dependencies
...but I am unsure of the syntax to add .NET Framework 4.7.1 so that it gets properly installed (if not already there) on target systems for my app.
Thanks!
If the app has 4.7.1 as a prerequisite, they will need to set their minversion to 16299 (Fall Creators Update).
In general, you cannot redist .NET with your app package, as it comes with the OS. But if you require a specific version, you need to make sure the minversion matches the update of Win10 that includes that specific version. You could use this table to look it up: .NET Framework Versions and Dependencies.

Xamarin.iOS project: CS1703: Multiple assemblies with equivalent identity have been imported

I've got a cross platform (iOS and Android) Xamarin solution using .NET Standard 2.0. The solution is being built by Visual Studio 2017 (I've tried both the current and preview versions). The Forms and Android projects build fine. However, the iOS fails to build, with the following error:
1>CSC : error CS1703: Multiple assemblies with equivalent identity have been imported: 'C:\Users\newuser.nuget\packages\system.reflection.emit\4.3.0\ref\netstandard1.1\System.Reflection.Emit.dll' and 'C:\Program Files (x86)\Microsoft Visual Studio\Preview\Enterprise\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\Xamarin.iOS\v1.0\Facades\System.Reflection.Emit.dll'. Remove one of the duplicate references.
I've tried many work arounds as described here:
oren.codes
www.hanselman.com
github.com/NuGet
Unfortunately none of these suggestions work. I have also tried to add the System.Reflection.Emit nuget package directly to the Forms and/or to the iOS projects directly. This doesn't work either. Note that originally, the The System.Reflection.Emit package wasn't referenced directly by anything in the solution. It is being pulled in by the following nuget packages which are being explicitly referenced:
Acr.DeviceInfo (5.0.5)
akavache (6.0.0-alpha0038)
AutoMapper (6.2.2)
Microsoft.Identity.Client (1.1.1-preview0040)
Newtonsoft.Json (10.0.3)
Finally, I have tried the update-package -reinstall command in the package console to reinstall all packages for the iOS project. This doesn't work either.
-- update
Just to make this clear, neither the Xamarin Forms or the Xamarin iOS project directly reference System.Reflection.Emit. That package is being pulled in as a dependency of other nuget packages, just from packages that are installed into the Xamarin Forms project. I have confirmed all of the dependencies that are referenced by Nuget, are using the same version. See these screenshots:
It seems to me that the problem (as the error says) is that there is an old version of System.Reflection.Emit that was installed by Visual Studio. However, I can't find a way of ignoring it and using the version of System.Reflection.Emit instead. As I've said above, I have tried to use a project.json file in the Xamarin.iOS project, and manually ignoring, but this doesn't work.
Does anyone else have any ideas?
As an aside, I notice that this bug is still open for Xamarin.
Xamarin Bugs
Managed to get this resolved thanks to an answer by #DirkWilhem on Xamarin Forums site.
Basically, add this to your Xamarin iOS project's .csproj file, with the other PackageReference nodes:
<PackageReference Include="System.Reflection.Emit">
<Version>4.3.0</Version>
<ExcludeAssets>all</ExcludeAssets>
</PackageReference>
Of course you need to make sure the nuget package has been added to the iOS package first.
Xamarin Forums discussion
After spending hours trying to resolve this myself I may have found a solution. Although it does feel wrong, it has got me past the issue.
Moving/Deleting the Xamarin.iOS version of System.Reflection.Emit.dll has solved the build problem for me and enabled me to deploy and run my app on a device. I don’t know what side effects it might have so will need more testing but I thought I’d share what’s worked for me so you can test it as well.
I was running on macOS Visual Studio 2017 but switched over to Windows to try and fix and first fixed on there then tried same approach on macOS and it worked as well.
On windows, go into the following directory and move the System.Reflection.Emit.dll somewhere else (you could just straight up delete it but I wanted to keep a copy I case this has some undesired effects down the track):
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\Xamarin.iOS\v1.0\Facades
On mac the following directory has it:
/Library/Frameworks/Xamarin.iOS.framework/Versions/Current/lib/mono/Xamarin.iOS/Facades
Like I say, it feels wrong but for now it’s got me past an issue that’s had me blocked for a couple of days so willing to just move on and hope there’s no side effects. I’d be interested to know your experience with it and if you come across anything else for the future too.
I’ll post this same comment on the Xamarin forums post (https://forums.xamarin.com/discussion/120814/xamarin-ios-project-cs1703-multiple-assemblies-with-equivalent-identity-have-been-imported) as well for future reference.
I had the same issue around a custom Nuget packages that we created and consumed in a separate project. We got around this issue by removing the automatic Nuget building checkbox in the "options" for the project. This does add the extra step of "Create Nuget Package" but one we pushed it to our Nuget repo and consumed it in our project, the errors vanished.
The problem showed up when we updated the sub-projects from PCLs to .netstandards (2.0).

Realm support for Swift 3

So I updated to swift 3.0 and now my projects with realm 1.0.2 all give me an error.
RealmSwift compiled with older version of Swift language (2.0) than previous files (3.0)
I also tried to build a net new project and still get the build error, so I know it is not a conversion issue on the Swift side.
I found several Swift 3.0 beta users and tried to run the script to update my version to 3.0 and several other options. The last few posts appeared to use Cocoa Pods - which I don't currently use. Is that the supported fix path?
Any help or direction would be greatly appreciated.
I haven't tried it yet, but here is what should work.
Essentially, the compiler gives you a description of what went wrong. The framework was compiled with Swift 2.0, while your project or other files were compiled with Swift version 3.0 (which means you made the switch after upgrading to the new version of Xcode.
To fix this, you need to use the Realm framework compiled with a Swift 3.0 compiler. Since the Realm team doesn't yet provide a precompiled version compiled with Swift 3.0, you have to do so yourself. To do that, go to their Github repository, and follow the instructions in the README under "Building Realm":
Prerequisites:
Building Realm requires Xcode 7.3.
Building Realm documentation requires jazzy
Once you have all the necessary prerequisites, building
Realm.framework just takes a single command: sh build.sh build.
You'll need an internet connection the first time you build Realm to
download the core binary.
This should generate the Realm framework with the current compiler version, which you then just have to use to replace your current Realm framework with. After that, everything should compile as it used to.
As stated before, I don't know if this actually works, as I haven't tried it yet. I don't exactly know if Swift 3.0 is supported by Realm yet or if there are any other issues you could run into. So please let me know how this works out!

Package restore failed ASP.NET 5

I am experiencing an issue with package restoring from NuGet repository in Visual Studio 2015.
When I am creating a new ASP.NET 5 project the dependencies related to ASP.NET 5 don't seem to be downloaded and added to my new project and I get that exclamation mark in yellow triangle sign next to each reference, instead.Solution Explorer.png
Well, obviously, I can't build a solution as the dependencies are highlighted red in project.jason.
When I hit Restore Packages option in my Solution Explorer the packages don't get restored and I get that Package restore failed message. In the output I can see that it fails due to an exception at System.Security.Cryptography.SHA256Managed..ctor()
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidOperationException: This implementation is not part of the Windows Platform FIPS validated cryptographic algorithms.
at System.Security.Cryptography.SHA256Managed..ctor()
--- End of inner exception stack trace ---
Output window.png
I am using latest DNX (1.0.0-rc1-update1 clr x64), in fact I've tried to use different DNXs none of them worked as it supposed to. Also I've tried to reinstall ASP.NET 5 bundle; to repair Visual Studio 2015; uninstalled and installed NuGet package manager in different ways; tried to delete NuGet.Config from AppData\Roaming\NuGet, manually deleted files from AppData\Local\Microsoft\VisualStudio; restored default settings, but none of the above solutions worked for me.
The only "sort of fix" which did something for me was cmd prompt "dnu restore" command in project folder. It resolved my initial dependecies "Microsoft.AspNet.IISPlatformHandler" and "Microsoft.AspNet.Server.Kestrel" and I managed to build the project. I thought it would be it, but, in truth, it didn't do much: I am stil not able to add any new dependency, even if I type it in manually in project.jason the NuGet package manager fails when trying to resolve it.
The question is: has anyone experienced similar issues? How can I force NuGet manager to resolve ASP.NET 5 dependencies?
Any advice is appriciated. Links to the articles, threads, comments are welcomed.
Your development machine has the FIPS algorithm policy enabled and therefore labels this implementation of SHA256 as invalid. .NET does offer a FIPS compliant implementation: SHA256CryptoServiceProvider.
If you have no idea why your machine is set to be FIPS compliant, your administrator might be able to help you out. Since this can be a requirement or even regulation in your industry, I'd try to make sure. There are ways to disable the FIPS mode in case you're sure that you don't have to be compliant.

Can't create new projects in VS2013 -- most references are missing

About a week ago I noticed strange behavior with my install of Visual Studio 2013 Pro. Creating new projects always results in missing references to EntityFramework and most of the Microsoft.* components. I had reinstalled .NET 4.5 in repair mode around that time but can't recall if this problem happened before or after that install.
As it stands, I can no longer create a functioning project. I have an existing project I'm working on that will compile and run without issue, but creating any new projects (which I need for spike solutions etc) is no longer possible until this is fixed.
Screenshots follow. These are all from creating a new MVC project with all defaults accepted.
References list showing missing references
Error list upon building
Reference paths are empty (this was mentioned in another answer that did not directly address my specific question, so I'm including it)
Regedit showing .NET versions installed
Even though I have "repaired" .NET 4.5 it appears from regedit that I only have up to .NET 4 installed? Am I reading that correctly?
Also, due to network restrictions I cannot download packages from Nuget automatically -- I have to download them manually from a laptop off-network and then sneakernet them over to install. The network physically blocks all connections to Nuget, github, etc.
If allowing VS to connect to Nuget is the only viable option then I have considered installing VS on the laptop, creating the project there and installing all necessary dependencies, and then moving the project folder over to the restricted computer and continuing from there. But I don't know if that is a solution to this problem or not.
Any advice appreciated, thanks.
.
The network blocks all connections to Nuget, github, etc.
It's almost like they don't want you to be productive.
Anyway the project templates (which you seem to be talking about) reference specific NuGet packages. Packages by default are stored relative to your solution.
Place a nuget.config in your disk's root (or any point into your projects directory, if you keep them organized like C:\Dev\Visual Studio\Projects, then each of those subfolders will be file) and point in that file to a shared package directory on your development machine. Here you can dump all packages you require.

Resources