Package restore failed ASP.NET 5 - asp.net

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.

Related

System.DllNotFoundException in .NET Core application

In a .NET Core application, I'm getting this error when I try to run my unit test project:
System.DllNotFoundException: Unable to load DLL 'opencv_core246' or one of its dependencies: The specified module could not be found. (0x8007007E)
The DLLImport line simply uses 'opencv_core246' (no path), so my understanding is that the runtime should look in the same directory as the executable itself (or failing that Windows/System32 or Windows/SystemWOW64). It is now in all three locations just for the hell of it, but still no dice. My colleague has the same set-up (mine is a Windows VM running in Parallels on a Mac whereas as his is native Windows but that shouldn't matter) and his tests run OK. Any ideas about how to debug this one appreciated.
First of all, please don't spray DLLs all over your system. That just makes life complicated. Remove the DLLs in the system directories and never modify those directories again. They belong to the system, not you.
Now, you will get the DllNotFoundException if the DLL cannot be found, or one of its dependencies cannot be found. The DLL will be found since its alongside the executable. Ergo, one of the dependencies cannot be found. Find out what the dependencies are, and make sure they can be resolved.
I'm adding my own answer in case this is helpful to someone else. As the accepted answer indicates, I was indeed missing dependencies of the native dll (opencv_core246). The thing is how to find out what these dependencies are. I used a utility called dependency walker, but this gave rather confusing results - it seemed to indicate I was missing the windows kernel! What clarified the issue was using the dumpbin utility which comes with Microsoft's C++ compiler. You can use this like so:
dumpbin /DEPENDENTS <my.dll>
This indicated that my dll had three dependencies, the kernel plus two that are part of the C++ redist package which was not installed on my system. Installing that fixed the missing dependency issue.
EDIT: Actually dependency walker results dig deeper into the dependency tree than dumpbin, so you can use it to get the same results. The dll dependencies are at the top level of the results tree.

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).

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.

Missing dependencies in latest rdfWebDeploy

I am trying to deploy a sparql endpoint using dotNetRDF to www.myapp.com/sparql.
rdfWebDeploy -test worked without errors but then running -deploy shows that there are missing assemblies in these tool.
First is complained about missing NewtonSoft.Json.Net35.dll, so I went into my nuget package and grabbed the dll in the net35 folder. However, this dll is named NewtsonSoft.Json.dll despite the 35 build...so I just renamed it has Net35 in the name and dropped it into rdfWebDeploy.
This worked so far, then it complained about MySql.Data.dll. I downloaded the MySql Connector which had the dll and dropped it into the rdfWebDeploy folder as well.
Finally rdfWebDeploy succeeded, however running the site produced
Could not load file or assembly 'Newtonsoft.Json.Net35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference.
How can I get this tool to deploy to my Net 4.5 MVC site and get past this Newtonsoft issue? Also, how will I know my endpoint ("/sparql") is working, will it display something if I go there?
This tool hasn't been updated in a while and sounds like it has fallen behind the main code base somewhat, we haven't used the old .Net 3.5 builds of Json.Net in a long time nor do we have any dependencies on MySql.Data anymore. So this sounds like a bug which we'll look to fix in our latest release - this has been logged as TOOLS-424
In terms of what you will see when this is working it will depend on the configuration you have provided for your endpoint(s), a fairly default configuration would give you a query form such as the one seen on our live demo at http://www.dotnetrdf.org/demos/leviathan/ - you can see the corresponding configuration for our demos at http://www.dotnetrdf.org/demos/sampleConfig
Update
The mentioned bug has now been fixed and an up to date and working version of this tool will be available in the next dotNetRDF release currently scheduled for the end of July 2014.

STS: Losing references in Java Build Path

I am using Spring Source Tool Suite 2.8.1 to implement Spring applications.
I frequently get build errors because references are lost for no apparent reason. In Right-click project in Package Explorer->Properties->Java Build Path->Order and Export, I find projects sometimes are deselected. And often packages are gone in Right-click project in Package Explorer->Properties->Java Build Path->Deployment Assembly.
Having to reset these settings frequently is frustrating. Is there some way I can work around these problems?
I have tried to update STS to the latest version, but the upgrade process fails with incomprehensible error messages. I want to avoid a clean install because setting up the environment again would probably be a nightmare.
Now that I know this is a maven project and you are adding references yourself, this is making sense to me. STS 2.8.x was the last STS to ship with the legacy m2e (maven plugin for Eclipse). It did not recognize build path entries added manually (it likes to have complete control over the classpath). So, what is likely happening is that you are adding these classpath entries and then an update project operation gets kicked off automatically. This will have the effect of removing all of your extra classpath entries.
You are best off doing the following:
Updgrading STS
Or just upgrading your m2e component (you will have to first uninstall the old m2e, but this should be taken care of automatically from the discovery update page).
Or, just accept the fact that you can't manually change your classpath with the legacy m2e.

Resources