I have been trying out the DotNetOpenAuth samples with ASP.Net MVC 4 Developer Preview.
I can successfully invoke my Action from my test page, but run into a strange issue because of one line of code:
var request = _openid.CreateRequest(openIdUrl);
var fetch = new FetchRequest();
fetch.Attributes.AddRequired(WellKnownAttributes.Contact.Email);
fetch.Attributes.AddRequired(WellKnownAttributes.Name.First);
fetch.Attributes.AddRequired(WellKnownAttributes.Name.Last);
request.AddExtension(fetch);
//return RedirectToAction("Login");
return request.RedirectingResponse.AsActionResult(); // <-- This is the line throwing the error
If I comment out the offending line of code and uncomment the one before this, I do not see the runtime error anymore.
So far I have tried:
1) Ensuring that I have the correct redirects:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0" newVersion="2.0.0.0" />
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
</dependentAssembly>
</assemblyBinding>
<legacyHMACWarning enabled="0" />
</runtime>
2) Have the correct namespaces:
using DotNetOpenAuth.OpenId.Extensions.AttributeExchange;
using DotNetOpenAuth.OpenId.Extensions;
It seems to me that the DotNetOpenAuth dll was compiled against MVC V 1.0.0 and the binding redirect is either not working or the extension method was maybe working against a deprecated method.
MVC Version: 4.0.0.0
DotNetOpenAuth Version: 3.4.7.11121
Any help on getting this working with MVC 4 would be greatly appreciated.
The MVC error screen image is further below:
Image of Error Screen
Update
I found that AsActionResult is the cause of the issue, maybe because the extension method is not compatible with .Net 4.0. I can get the OutgoingWebResponse object from request.RedirectingResponse but do know how to cast it to an ActionResult
It appears your binding redirects are corrupted. Notice how System.Web.Mvc appears twice? Try removing the second one as the first one looks correct.
Yes, DNOA is built against MVC 1.0, and this is by design so that it works against all versions of MVC (given the appropriate redirects). This is purely an MVC version thing -- not a .NET 4.0 thing.
Related
I'm using JSON.NET in a Visual Studio extension and it's not included in the distribution (by design by Microsoft).
In the linked ticket they simply state that v9.0.1 should be used. And that supporting multiple VStudio versions "complicate things".
Another SO question gives and answer which doesn't work in all cases.
I use a nuget package which in turn depends on Newtonsoft.Json 10.0.x. Is there any way that I can continue to use JSON.NET v10.x without causing any trouble for Visual Studio?
One possible solution is to use AppDomain and wrap all Newtonsoft.json related call within new AppDomain:
myDomain = AppDomain.CreateDomain("myDomain", AppDomain.CurrentDomain.Evidence,
new AppDomainSetup()
{
ApplicationBase = extensionPath,
ConfigurationFile = Path.Combine(extensionPath, configurationFileName)
});
The file configurationFileName should be shipped with your extension and its content looks like:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-10.0.0.0" newVersion="10.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
We have migrated from TFS 2010 to TeamCity and we have issues in building our solution file.
We are using .NET 4.0.
Google library is notoriously causing issues with .NET 4.0 + system.net.http when trying to build it.
We managed to get this setup working on TFS(it uses MSBuild 4.0) without errors.
App.config should have correct assemblybindings:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.6.9.0" newVersion="2.6.9.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.6.9.0" newVersion="2.6.9.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.2.28.0" newVersion="2.2.28.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Net.Http.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.2.28.0" newVersion="2.2.28.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
We have already tried:
- Use different runner types: Visual studio, MSbuild
- Referenced all Dlls directly(google+system.net.http+etc.)
- Use straight Nuget Package restore on these DLLs(it restores everything ok)
Build error is:
ResolveAssemblyReference] C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets(1635, 5): warning MSB3268: The primary reference "Google.Apis.Auth.PlatformServices, Version=1.9.0.26016, Culture=neutral, processorArchitecture=MSIL" could not be resolved because it has an indirect dependency on the framework assembly "System.Net.Http, Version=2.2.22.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which could not be resolved in the currently targeted framework. ".NETFramework,Version=v4.0". To resolve this problem, either remove the reference "Google.Apis.Auth.PlatformServices, Version=1.9.0.26016, Culture=neutral, processorArchitecture=MSIL" or retarget your application to a framework version which contains "System.Net.Http, Version=2.2.22.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
Followed by:
[07:58:29]W: [MSBuild output] C:\BuildAgent\work\dda43f1992063b18\Integrations\CalendarSync\Devices\Google Calendar\GoogleCalendarDevice.vb(788,78): error BC30009: Reference required to assembly 'Google.Apis, Version=1.9.0.23042, Culture=neutral, PublicKeyToken=null' containing the implemented interface 'Google.Apis.Requests.IDirectResponseSchema'. Add one to your project. [C:\BuildAgent\work\dda43f1992063b18\Integrations\CalendarSync\Severa.Integrations.CalendarSync.vbproj]
We now have non optimal solution to the problem.
MsBuild finds wrong version from one of these locations:
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0
C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 4\Packages\Microsoft.Net.Http.2.0.20710.0\lib\net40
C:\Program Files (x86)\Microsoft Web Tools\Packages\Microsoft.Net.Http.2.0.20710.0\lib\net40
This is wrong since the version in these locations is: 1.0.0.0.
If we replace all these places with 2.2.28 version it works..
We have tried following:
Compliation.config add assembly
Web.config bindingredirect
Sln file hints to right packages..
Unfortunately our TC agents are in shared environment so we can't replace this files in all these locations.
Any ideas?
I am trying to learn ASP.NET MVC with Adam Freeman's "Pro ASP.NET MVC 5" book. Unfortunately all projects using Ninject throw the same error
An exception of type 'System.IO.FileLoadException' occurred in Ninject.dll but was not >handled in user code
Additional information: Could not load file or assembly 'System.Web.Mvc, >Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its >dependencies. The located assembly's manifest definition does not match the assembly >reference. (Exception from HRESULT: 0x80131040)
This is exactly the same problem which was discussed in this thread,
Issues after installing ninject mvc 3 in mvc 5 project
but the offered solutions don't work for me.
I have tried target platforms 4.5 and 4.5.1, Ninject MVC3 and MVC5. I have also inserted this snippet
<runtime>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
</dependentAssembly>
</runtime>
in the Web.config file, without any effect.
Problem must be in the Ninject MVC3 and MVC5 packages. Whenever these packages are installed, any call to Ninject.StandardKernel() throws the exception, regardless if made from the Global.asaxor the new NinjectWebCommon.cs or from any other piece of code (of course, this should not matter for this kind of exception anyway, but in this thread Error using Ninject with ASP.NET V4 it was suggested that the error might have something to do with using the Global.asax for connecting Ninject to the application).
I have run out of ideas. Can anyone help?
Add to your Web.config (i.e. SportsStore.WebUI project):
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
It should work with this -> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
All, I am stuck in a problem which drive me crazy... please help to review it . thanks in advance.
I want to reference a NHibernate.dll to my website with the version number 2.1.0.4000.
But I didn't know why the website always to search the NHibernate.dll of version number 2.1.2.4000 when I try to debug it.
Here is what I try to do .
try to use fuslogvw to trace the assembly binding .
you can see the application want to bind the 2.1.2.4000 which is not my desired version.
remove all the reference of Nhibernate in my solution. and add the right one again.
To the website project. I found the dll I just added show auto update in the version number column instead of the right version number in the reference dialog. I don't why.
Could someone please help to give me some idea to figure out what happened to it . thanks. any comments are welcome.
updated
I searched with key text "NHibernate" in the Web.Config
the content about it is below.
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Iesi.Collections" publicKeyToken="aa95f207798dfdb4"/>
<bindingRedirect oldVersion="1.0.0.3" newVersion="1.0.1.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="NHibernate" publicKeyToken="aa95f207798dfdb4"/>
<bindingRedirect oldVersion="2.0.1.4000" newVersion="2.1.0.4000"/>
</dependentAssembly>
</assemblyBinding>
<assemblyBinding appliesTo="v2.0.50727" xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Oracle.DataAccess" publicKeyToken="89b483f429c47342" processorArchitecture="amd64"/>
<bindingRedirect oldVersion="2.102.4.0" newVersion="2.112.2.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Oracle.DataAccess" publicKeyToken="89b483f429c47342" processorArchitecture="ia64"/>
<bindingRedirect oldVersion="2.102.4.0" newVersion="2.112.2.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
updated
I checked dll in the Reflector, Anything wrong with it ?
Updated
The manifast of ILdasm shows below
Updated
Sometimes I found the log shows some clue which assembly reference the wrong dll.
you can see "Calling assembly: xxxx.dll, version=........."
It looks like its an issue with your dll file itself. The manifest of the .dll file has declared the version details in a wrong way. Try to download another copy of the file from some other resource. Now clean your solution, add a reference to it and rebuild the solution. The error should go.
I'm having trouble with the most basic example https://github.com/SignalR/SignalR/wiki/QuickStart-Persistent-Connections. I get "404 on echo/negotiate"
The example is out of date.
It's because the default MVC-project calls RegisterRoutes(RouteTable.Routes);
You have to move the MapConnection to inside the RegisterRoutes, after the routes.IgnoreRoute("{resource}.axd/{*pathInfo}"; but before any other routes.
I hope this helps
I got the exact same error when trying to implement the basic persistent connection sample, and it took me quite a while to realize that it was due to a version mismatch for Newtonsoft.Json, problem and solution described here:
https://github.com/SignalR/SignalR/issues/195
That is, add a section like:
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.8.0" newVersion="4.0.8.0" />
</dependentAssembly>
to your web.config.
Don't know why that section was missing for me since as far as I understand it should be added automatically by nuget, perhaps something to do with Visual Studio 11 beta. Anyhow, it was the solution to my problem.
There are two steps :
1. In web.config add or edit rule json
<dependentAssembly> <assemblyIdentity name="Newtonsoft.Json"
publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.8.0" newVersion="4.0.8.0" />
</dependentAssembly>
2. In Global.asax Add new:
RouteTable.Routes.MapConnection<ChatConnection>("negotiate", "/chat");
In method protected void Application_Start(){}
Good luck !