Microsoft.Practices.EnterpriseLibrary.Common - unity-container

I have been using previous version of unity extension. Now I have to upgrade my project with a newer version of Unity Extension.
I have code in my previous version as :-
Microsoft.Practices.EnterpriseLibrary.Common.Configuration.Unity.UnityContainerExtensions.AddNewExtensionIfNotPresent<Microsoft.Practices.Unity.InterceptionExtension.Interception>(Context.Container);
this.Context.Container.AddExtension(new ContainerRegistration());
But in new version Unity is not found under Configuration, has it moved to a new method?

The Unity building block can be installed with NuGet. You can get more informations here, or by opening the package manager in Visual Studio and searching for Unity.
The class you're looking for are now in another namespace. For example, UnityContainerExtensions is in Microsoft.Practices.Unity. I'd recommend adding a using on top of the classes where you're dealing with the UnityContainer to simplify the reading.

Related

.net 6 BuildServiceProvider is missing

net 6, create console application with 'minimal template'. try add DI but BuildServiceProvider is missing. I try google about how migrate ServiceCollection but did not find nothing.
var services2 = new ServiceCollection();
var serviceProvider = services2.BuildServiceProvider();
In my idiotic case, I was using Microsoft.Extensions.DependencyInjection.Abstractions instead of Microsoft.Extensions.DependencyInjection. I didn't notice at first because ServiceCollection, AddSingleton etc were available using the first NuGet as well. Icon and author are the same for both NuGets.
The following two steps fixed it for me (VS2022, .NET Standard 2.0):
Make sure all your projects are referring to the same version of Microsoft.Extensions.DependencyInjection. At the time of this writing, the latest version is 7.0.0. You can use Consolidate tab in solution's Nuget Configuration page to achieve this.
Go to project's Nuget Configuration page (and not Solution's Nuget Configuration page) by right-clicking the problematic project and choosing Manage Nuget Packages. Therein, uninstall Microsoft.Extensions.DependencyInjection and then re-install it (again making sure you're using the same version as other projects in the solution).
Rebuild the solution after this and things should look good.

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

Unable to use SQLite in VS2017 universal windows platform project

I try to use the SQLite in the VS2017 in a universal windows platform project. I follow the guidance to download the SQLite extension for VS2015 although my local machine environment is VS2017, maybe this is the root cause? Then I add the reference with SQLIte. After that I installed the SQLitePCL with nuget.
After the SQLite installed, I wanted to try to run a demo to see if it can work right. But I found I can't using the namespace (using SQLite.Net.Attributes;) which it necessary for my demo.
I did some search about the SQLite and VS2017, But didn't found too much about such circumstances. So I want to know if anyone ever met such problem and How can your fix that?
Or it just unavailable to using SQLite in VS2017? If yes, can I complier a newest version about this?
Thanks everyone who can give me some reply or suggestion about this issue.
But I found I can't using the namespace (using SQLite.Net.Attributes;)
It seems like SQLite.Net.Attributes is belong to the Nuget package SQLite.Net-PCL, not SQLitePCL, the one you are using. SQLitePCL does't contain SQLite.Net.Attributes. You may obtain the package that is not you attempt to use.
There're many Nuget packages for SQLite, some of them are older with long time no updating. For UWP app, I'd recommend you to follow this tutorial to use a SQLite database in a UWP app.

Referencing class library in ASP.NET 5 - dependency issues

My custom class library (targeting .NET 4.5.1) references Newtonsoft.Json 8.0.2 (the latest version to date). I've added this class library as a reference to a new ASP.NET 5 Web API project.
From the Error List output:
Error NU1002 The dependency Newtonsoft.Json 1.0.0 in project MyProject does not support framework DNXCore,Version=v5.0.
That part seems somewhat self-explanatory, however, I couldn't understand why it was changing my referenced version to 1.0.0.
From the References --> DNX 4.5.1 --> MyClassLibrary Node:
NU1007 Dependency specified was Newtonsoft.Json >= 8.0.2 but ended up with Newtonsoft.Json 1.0.0.
I've tried removing/re-adding the references several times, all to no avail. I did notice that several of the ASP.NET libraries use Newtonsoft.Json 6.0.6 -- I'm not sure if this has anything to do with it.
If I navigate to the wrap folder --> Newtonsoft.Json --> json file, and replace "Newtonsoft.Json 1.0.0-*" with "Newtonsoft.Json 8.0.2-*", it fixes the references for the DNX 4.5.1 node.
However, errors still show afterwards saying that Newtonsoft.Json 8.0.2 referenced in my class library does not support DNXCore 50.
I'm at a loss as to what to do. Any help would be greatly appreciated.
Answer to my issue:
Thanks to Oleg's response I was able to make it work -- however there were two hurdles. One was the "wrap" folder that was created for Newtonsoft.Json. In the root of my solution was a "wrap" folder that contained a folder called Newtonsoft.Json. Apparently(?) that folder shouldn't have been created (how it was created I have no idea). Once removing that, I was able to add a reference to my custom class library without any errors referencing Newtonsoft.Json.
However when I began trying to use my custom assembly as in code, I would get an error about DNX50 not being supported -- which sort've makes sense because my custom referenced assembly was a .NET 4.5.1 class library.
This GitHub link has many people experiencing a similar issue
However, I managed to get everything to build and errors to go away by removing targeting for DNXCore50. This worked for me because I was just wanting to share some POCO data models between a Web API and WPF project. I'm not interested in targeting DNXCore at the moment.
I'm looking forward to the future of ASP.NET, but the newness is a bit challenging, at least for me.

Can not find system.web.http

I have to add a system.web.http assembly reference because I added the HttpConfiguration class to my unit test class library project.
When I browse the Add reference dialog I can not find the system.web.http assembly.
The class library project has the .Net 4.5.1 framework targeted.
in order to get the system.web.http you will need to install a nuget package
in the nuget command line:
Install-Package Microsoft.AspNet.WebApi.Core
https://www.nuget.org/packages/Microsoft.AspNet.WebApi.Core/
I've had multiple errors regarding missing references such as "system.web.http" or "system.web.razor" in my project. Even though I do have all the references installed through nuget.
What worked for me was to install a standalone version of AspNetMVC4, even though Visual Studio 2014 installed that as well. Apparently it was missing some references in Windows. I've installed this from the Microsoft website, and all went well afterwards.
Hope this helps someone. It drove me crazy for like 2 days, nothing regarding nuget worked for me, I've deleted and reinstalled the references a couple times, did everything I've found in multiple posts on stackoverflow, nothing worked.
Url for mvc4 standalone setup from microsoft: https://www.microsoft.com/en-us/download/confirmation.aspx?id=30683
For every one haveing this problem. Remember that you might have a downgraded version of based on your framework. Try look on your packagde folder what version you have. Then upade that version. Dont use Update-Package it will update all version with no respect to the framework your running at all.
It was solved by commenting out the "bindingRedirect" part.
bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.2.0.0"/

Resources