SignalR Persistent connection giving 404 on echo/negotiate - signalr

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 !

Related

Including Json.NET in a Visual Studio extension

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>

Error On Item Saving-Field not found: 'Store.COMPRESS'

I'm getting the "Field not found: 'Store.COMPRESS'" error when I try to save item.
Earlier I was getting Lucene version error of Lucene version 2.9.4.1 ,so I updated the following setting in web.config:
<dependentAssembly>
<assemblyIdentity name="Lucene.Net" publicKeyToken="85089178b9ac3181"/>
<bindingRedirect oldVersion="0.0.0.0-2.9.4.0" newVersion="3.0.3.0"/>
</dependentAssembly>
to
<dependentAssembly>
<assemblyIdentity name="Lucene.Net" publicKeyToken="85089178b9ac3181"/>
<bindingRedirect oldVersion="0.0.0.0-2.9.4.1" newVersion="3.0.3.0"/>
</dependentAssembly>
-Vikram
Store.COMPRESS is a Lucene 2.x feature that is no longer supported in 3.x. Your assembly redirect bindings only fixes the bindings, not the actual implementation of Lucene.
Looks to me like you have Lucene 2.x code running in your solution; it will need to be upgraded/rewritten for Lucene 3.x.
Javadoc for Field.Store: http://lucene.apache.org/core/2_9_4/api/core/org/apache/lucene/document/Field.Store.html
Note that it now lists as deprecated.
SO Post here: Field.Store.COMPRESS in Lucene 3.0.2

FileLoadException after installing Ninject.MVC5

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

How to find the wrong reference dll in website when debug

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.

DotNetOpenAuth with MVC 4.0

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.

Resources