Creating interceptors with Autofac and MVC3 - asp.net-mvc-3

I need to create a performance monitoring interceptor that will be hooked up via Autofac. Unfortunately, it's for an MVC3 project, meaning that I'm using Autofac 2.6.3, because Autofac 3 is only compatible with MVC4. As such, I cannot use the Autofac.Extras.DynamicProxy2 Nuget package, because it isn't compatible with MVC3.
I've found AutofacContrib.DynamicProxy2, which is compatible with Autofac 2.6.3. The problem is, the Nuget package doesn't install due to a version mismatch between the dependencies. The problem is highlighted below:
AutofacContrib.DynamicProxy2
Depends on 'Autofac (>= 2.4.5.724)'
Depends on 'Castle.Core (>= 2.5.2)'.
Depends on 'Castle.DynamicProxy (>= 2.2.0)'.
Depends on 'Castle.Core (= 1.2.0)'.
I get the following Nuget package install error:
Updating 'Castle.Core 2.5.2' to 'Castle.Core 1.2.0' failed. Unable to find a version of 'AutofacContrib.DynamicProxy2' that is compatible with 'Castle.Core 1.2.0'
How can I perform method interception with MVC3 and Autofac?

Looks like I can install 'DynamicProxy2', thanks to this article
Basically, after installing AutofacContrib.DynamicProxy2 and getting the error, I need to install it again with the -ignoredependencies flag and it installs OK.
Run this command:
install-package autofaccontrib.dynamicproxy2
Followed by this command:
install-package autofaccontrib.dynamicproxy2 -ignoredependencies

Related

Installing Microsoft.Extensions.DependencyInjection in .NET Framework 4.7.1 project

I'm attempting to install the Microsoft.Extensions.DependencyInjection and Microsoft.Extensions.DependencyInjection.Abstractions 2.0.0 nuget packages into a .NET Framework 4.7.1 project (Microsoft.AspNet.OData), however I'm getting the error:
Could not install package 'Microsoft.Extensions.DependencyInjection
2.0.0'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.7.1', but the package does not
contain any assembly references or content files that are compatible
with that framework. For more information, contact the package author.
The dependency for these packages is .NETStandard,Version=v2.0. I understand that .NET Standard isn't .NET Framework, however I thought that .NET Framework 4.6 and greater projects could install .NET Standard projects? If this isn't possible, then are there other equivalent versions of these nuget packages for .NET Framework?
The whole reason that I'm going through this exercise is because many developers are completely blocked by Microsoft.AspNet.OData only supporting DI 1.0, not 2.0. This means that we cannot upgrade our nuget packages in our OData web api, as other packages require DI 2.0 but OData is stuck on 1.0. The rest of our applications are using the latest and greatest, so really it means that our OData web api solution can't leverage ANY of our shared code, and is completely quarantined until this compatibility block is resolved.
Installing Microsoft.Extensions.DependencyInjection in .NET Framework 4.7.1 project
I think the error message is not accurate. When I install the nuget package Microsoft.Extensions.DependencyInjection 2.0.0 to the project (Microsoft.AspNet.OData), I got the following error message:
Unable to resolve dependencies.
'Microsoft.Extensions.DependencyInjection 2.0.0' is not compatible
with 'Microsoft.AspNet.OData 7.0.0-beta2 constraint:
Microsoft.Extensions.DependencyInjection (>= 1.0.0 && < 2.0.0)'.
That is exactly what you said "because many developers are completely blocked by Microsoft.AspNet.OData only supporting DI 1.0, not 2.0."
Check the dependencies of package Microsoft.AspNet.OData, we could know there are strict restrictions for the dependencies Microsoft.Extensions.DependencyInjection and Microsoft.Extensions.DependencyInjection.Abstractions ((>= 1.0.0 && < 2.0.0))
So, this is really a issue that the package Microsoft.AspNet.OData don't support DI 2.0. Many other communities also report this issue on Github, but there is still no any workaround and solution.
My current workaround is:
Create a new project without installing package Microsoft.AspNet.OData.
Install the other dependencies of package Microsoft.AspNet.OData: Microsoft.OData.Core (>= 7.2.0 && < 8.0.0), Microsoft.AspNet.WebApi.Core (>= 5.2.2 && < 5.3.0) and Microsoft.AspNet.WebApi.Client (>= 5.2.2 && < 5.3.0) (The latter two packages should be included in the template by default).
Install the nuget package Microsoft.Extensions.DependencyInjection 2.0.0
Install the nuget package Microsoft.AspNet.OData with option -IgnoreDependencies in the Package Manager Console:
update-package Microsoft.AspNet.OData -IgnoreDependencies -IncludePrerelease
With this workaround, we could use Microsoft.AspNet.OData and DI 2.0, but I could fully confirm whether breaking the dependency limition will cause any problem for the Microsoft.AspNet.OData package. Simple tests are not problematic.
Hope this helps.

Is there an OData dependency graph somewhere?

I'm following this guide to migrate an app I developed to an open framework. I get to the part where I'm supposed to install all the OData references. Specifically these:
Install-Package Angularjs
Install-Package Microsoft.OData.Client
Install-Package Microsoft.OData.Core
Install-Package Microsoft.OData.Edm
Install-Package Microsoft.Spatial
Install-Package Microsoft.AspNet.OData
Install-Package Microsoft.AspNet.WebApi.WebHost
And these are the errors I get:
Unable to resolve dependencies. 'Microsoft.OData.Core 7.0.0' is not compatible with 'Microsoft.OData.Client 6.15.0 constraint: Microsoft.OData.Core (= 6.15.0)'.
Unable to find a version of 'Microsoft.OData.Core' that is compatible with 'Microsoft.OData.Client 6.15.0 constraint: Microsoft.OData.Core (= 6.15.0)'.
Unable to find a version of 'Microsoft.OData.Core' that is compatible with 'Microsoft.OData.Client 6.15.0 constraint: Microsoft.OData.Core (= 6.15.0)'.
Unable to find a version of 'Microsoft.OData.Edm' that is compatible with 'Microsoft.OData.Core 6.15.0 constraint: Microsoft.OData.Edm (= 6.15.0)'.
I started running my app over and over until it throws an exception and then adding a bingindRedirect to my Web.config to target the currently installed versions. But this doesn't seem right and will add a lot of maintenance later on. I know how to install old versions and nightly versions. But I have no idea which versions to install. Is there some place that tells me which versions work together correctly?
According to NuGet, I have version 6.15.0 of each installed. So why am I getting errors?
Microsoft.OData.Core, Microsoft.OData.Edm and Microsoft.Spatial were already installed after you run "Install-Package Microsoft.OData.Client" command since they are all the dependencies. You can check it from your project reference. So you don't need these commands anymore:
Install-Package Microsoft.OData.Core
Install-Package Microsoft.OData.Edm
Install-Package Microsoft.Spatial
And since the latest version of Microsoft.OData.Client is 6.15.0 which required Microsoft.OData.Core with version 6.15.0. All these packages are installed with version 6.15.0.
If you run the commands below:
Install-Package Microsoft.OData.Core -Version 6.15.0
Install-Package Microsoft.OData.Edm -Version 6.15.0
Install-Package Microsoft.Spatial -Version 6.15.0
You will get the message like following:
Package 'Microsoft.OData.Core.6.15.0' already exists in project
Another issue is that the latest 6.0.0 version of Microsoft.AspNet.OData requires Microsoft.OData.Core version >= 7.0.0 while the version you already installed is 6.15.0. So you need to install the 5.9.1 version which requires Microsoft.OData.Core > 6.14.0.
Install-Package Microsoft.AspNet.OData -Version 5.9.1
You could get the dependencies relationship from the NuGet Package Manager page from Project -> Manage NuGet Packages. When you select one of the package, it will show its dependencies on right side. You could select the package version to check which version of dependencies should be installed for current version of package.
The relationship for the OData packages should be OData.Client 6.15 dependent on OData.Core 6.15 and OData.Core 6.15 dependent on OData.Edm 6.15.
But in your project, you installed OData.Core 7.0 and OData.Edm 7.0, which are not compatible with OData.Core 6.15.
So please install the correct version of OData.Core 6.15 and OData.Edm 6.15.

Unable to add Xamarin Google Play Services

I'm unable to add GCM to my Xamarin app. This is the output from the package console:
Adding Xamarin.GooglePlayServices.Gcm...
Attempting to resolve dependency 'Xamarin.GooglePlayServices.Base (= 29.0.0.1)'.
Attempting to resolve dependency 'Xamarin.GooglePlayServices.Basement (= 29.0.0.1)'.
Attempting to resolve dependency 'Xamarin.Android.Support.v4 (≥ 23.1.1.1)'.
Attempting to resolve dependency 'Xamarin.GooglePlayServices.Measurement (= 29.0.0.1)'.
Updating 'Xamarin.Android.Support.v4 23.0.1.3' to 'Xamarin.Android.Support.v4 23.3.0' failed. Unable to find a version of 'Xamarin.Forms' that is compatible with 'Xamarin.Android.Support.v4 23.3.0'.
For this version you must install an earlier version of Xamarin.GooglePlayServices.Gcm. I had no problems with 27.0.0.
If you need the newest version, you could do this:
uninstall xamarin.forms nuget package
update all android packages to 23.3.0
install Xamarin.GooglePlayServices.Gcm
search for xamarin.forms and set in options ignore dependencies
install newest version
Of course you must be aware of problems, since this is not recommended with good reasons.
You need to Update your Xamarin.Forms package. Open Packages (Dropdown) in Solutions pane and Right-Click on Xamarin.Forms and click on Update
If you are using PCL, you can find this package in the PCL (Xamarin.Forms) project.
If you are using Shared Asset Project, you will find this package in both Xamarin.Android and Xamarin.iOS project.
You have to update Android SDK Platform-tools to revision 26.0.2 (or equivalent).
Open Android SDK Manager, check update, and select
"Update avaiable rev.26.0.2" and install it.

Change dependencies on NuGet package

I recently tried to upgrade my log4net to the new 2.0.0 version.
but I wasn't able to do so, cause I have another library (combres.mvc) that has a dependency for log4net 1.2.11
Install failed. Rolling back...
Updating 'log4net 1.2.11' to 'log4net 2.0.0' failed. Unable to find a version of 'combres' that is compatible with 'log4net 2.0.0'.
Now the combres is an open source which I can download here http://combres.codeplex.com/
Does any one know how can I fix this, that the combres library will support log4net 2.0.0 or any other future version that may come out?
I did tried to contact the publisher with no help, It seems that he is not supporting this library any more...

Microsoft ASP.NET Web API Odata nuget package is failing to install

Attempting to resolve dependency 'Microsoft.Data.Edm (= 5.0.1)'.
Attempting to resolve dependency 'Microsoft.Data.OData (= 5.0.1)'.
Attempting to resolve dependency 'System.Spatial (≥ 5.0.1)'.
Attempting to resolve dependency 'Microsoft.Net.Http (≥ 2.0.20710.0 && < 2.1)'.
Attempting to resolve dependency 'System.Spatial (= 5.0.1)'.
Already referencing a newer version of 'System.Spatial'.
Anyone got any ideas? why this package is not install? Google search is empty
Alex James posted on his blog that this has been fixed.
The issue was that ODataLib was released after this OData package was released and that broke the dependencies (version numbers didn't add up). Everything works now, at least for me.

Resources