Signalr: "signalr.exe ghp" doesn't generate Hub proxy JavaScript files

Created on 7 Nov 2012  路  12Comments  路  Source: SignalR/SignalR

run signalr.exe ghp

it creates empty server.js

and creates temp directory like D:\Users\xiaota\AppData\Local\Temp\6e31b06d-de50-4ddb-9b06-a8349446baf3 which only contains signalr.exe

Most helpful comment

Got it!
I debugged through this one. After this i saw my big mistake.
OK! First of all /path: means _path_. Not _path + filename_. Doh! My failure. Read first, then ask ;).

But in my case this was not the only thing why _signalr.exe_ creates a empty server.js.
In class JavaScriptGenerator in method public string GenerateProxy(string path, string url, Action<string> warning) i noticed this lines of code:

var signalrAssembly = (from a in AppDomain.CurrentDomain.GetAssemblies()
                                       where a.GetName().Name.Equals("Microsoft.AspNet.SignalR.Core", StringComparison.OrdinalIgnoreCase)
                                       select a).FirstOrDefault();

In my case ONLY SignalRChat.dll lies in my Directory. But as you can see the lines of code above you try to get the Microsoft.AspNet.SignalR.Core dll.
I copied Microsoft.AspNet.SignalR.Core.dll and all needed dependencies like the Newtonsoft.Json.dllin the directory where my SignalRChat.dl lies. And now it works!!
@horcu: Maybe this solution is working for you too.

All 12 comments

Where did you run it?

If I build the signalr solution from release branch I get the following error
Error 36 The command "C:\Users\pranavra\Documents\SignalR-release\src\Microsoft.AspNet.SignalR.Utils\bin\Debug\signalr.exe ghp /o:C:\Users\pranavra\Documents\SignalR-release\samples\Microsoft.AspNet.SignalR.Hosting.AspNet.Samples\Scripts\hubs.js" exited with code 3. C:\Users\pranavra\Documents\SignalR-release\samples\Microsoft.AspNet.SignalR.Hosting.AspNet.Samples\Microsoft.AspNet.SignalR.Hosting.AspNet.Samples.csproj 367 5 Microsoft.AspNet.SignalR.Hosting.AspNet.Samples

I don't see this fail at all.

not fail

Xiaohongt I am also getting a blank file doing exactly as y ou described in your initial comment. What did you do to resolve this.

@horcu , probably your dll for signalr hub is not in directory from where you run the signalr.exe, you can specify path param in commandline, like signalr.exe ghp /path:"c:\app\bin".

@Xiahongt I am 100% sure that the .dll file is in the bin folder and thats where I'm pointing to as the path for the signalr ghp call. I'm not sure what I'm doing wrong but just like you said previously, all I get is an empty server.js file and a newly created temp directory with a copy of signalr.exe in it. What am I doing wrong ? @davidfowl any direction on this? Maybe a way to generate the file build time?

Hi, is there any news about this issue?
@horcu I can confirm the described behavior.
I got this simple hub similar like this:

namespace SignalRChat
{
    public class ChatHub : Hub
    {
        public void Send(string name, string message)
        {
            // Call the broadcastMessage method to update clients.
            Clients.All.broadcastMessage(name, message);
        }
    }
}

After this i tried the following

  1. Open bash
  2. cd to the directory where signalr.exe lies.
  3. Call: signalr.exe ghp /path:"c:\blah\SignalRChat.dll"
  4. Result: as descripted by @horcu

And i tried something different

  1. Copy SignalRChat.dll to the folder where signalr.exe lies.
  2. Call: signalr.exe ghp SignalRChat.dll"
  3. Result: as descripted by @horcu

Does anyone have a cool advice for me to solve this problem?

Got it!
I debugged through this one. After this i saw my big mistake.
OK! First of all /path: means _path_. Not _path + filename_. Doh! My failure. Read first, then ask ;).

But in my case this was not the only thing why _signalr.exe_ creates a empty server.js.
In class JavaScriptGenerator in method public string GenerateProxy(string path, string url, Action<string> warning) i noticed this lines of code:

var signalrAssembly = (from a in AppDomain.CurrentDomain.GetAssemblies()
                                       where a.GetName().Name.Equals("Microsoft.AspNet.SignalR.Core", StringComparison.OrdinalIgnoreCase)
                                       select a).FirstOrDefault();

In my case ONLY SignalRChat.dll lies in my Directory. But as you can see the lines of code above you try to get the Microsoft.AspNet.SignalR.Core dll.
I copied Microsoft.AspNet.SignalR.Core.dll and all needed dependencies like the Newtonsoft.Json.dllin the directory where my SignalRChat.dl lies. And now it works!!
@horcu: Maybe this solution is working for you too.

I run the following command which is a path to my bin directory of my web application which contains the dll of where my hubs live. The SignalR core dll is also there but I still end up an empty server.js file.

signalr ghp "D:\Projects\myProject\bin"

Why must the documentation on how to use this be so poor?

Just ran into this issue myself. After running the utility in the debugger, I came to realize that I had issues with dependency versions. Specifically, my app had a dependency on Newtonsoft.Json 9.0.1 whereas Microsoft.AspNet.SignalR.Core has a dependency on version 6.0.4. More specifically:

Could not load file or assembly 'Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

I was able to successfully generate my server.js script by the following:

  1. Clone SignalR.
  2. Update the Newtonsoft.Json package (I also updated the Microsoft.Owen and Microsoft.Owen.Security packages to the latest versions) to match my app's dependencies.
  3. Build the SignalR project.
  4. Copy the Microsoft.AspNet.SignalR.Core DLL from the local bin folder into my app's directory.
  5. Remove the SignalR NuGet package(s) from my app.
  6. Add dependencies to the new local SignalR DLLs.
  7. Run the SignalR utility locally with the path argument pointing to my app's bin folder.

This is a very temporary solution. In fact, I'll probably revert my dependencies back to the official NuGet packages now that I have my script ...and documentation on how I got them 馃槈. I'm not sure if there is an easier/better way to resolve this issue. One possible work around that I've been considering--though it would require a change in the SignarlR utility code--is to attempt to load the SignalR.Core assembly from the specified path in the GenerateProxy method as opposed to loading it from AppDomain.CurrentDomain.GetAssemblies(). We could then load the assembly locally as a fallback, if the assembly was not found in the path directory.

What are your thoughts?

@vinneyk - Just had this happen myself. The problem is that we have a binding redirect in our app.config/web.config that redirects all requests for Newtonsoft.Json to version 9. Because signalr.exe is what's loading assemblies, it doesn't know about the redirect, and we get the exception. I've had the exact same thing happen with InstallUtil for installing a Windows service.

A workaround is to add a signalr.exe.config file in the same directory as signalr.exe with any needed redirect. After that, the command works as expected.

To make this process as dynamic as possible, I created a PowerShell script that can be ran as a post-build step. It'll copy all binding redirects from your app.config/web.config into signalr.exe.config, place both signalr.exe and the config in a temp folder, generate the proxy, and copy the proxy to a specified output folder. I also tried to keep direct path references to a minimum, so the Utils package can be upgraded down the road without breaking the script. :-)

https://gist.github.com/jcoutch/b61ec7d7d3f4f37295e905aa99d1b9a7

Was this page helpful?
0 / 5 - 0 ratings