signalr generating error while creating server.js file

0

I'm creating Chat Application for Android using Xamarin under Visual Studio 2015 Pro. I want to create a physical file for the SignalR generated proxy describe Here: SignalR Hubs API Guide So as stated I install the Microsoft.AspNet.SignalR.Utils NuGet package. And I tried:

signalr.exe ghp /path:"D:\WORKS\VISUALSTUDIO\ASPWEBSITE\ServerSignalR_ChatHub\ServerSignalR_ChatHub\bin"

but it always gives below error:

SignalR Utility Version: 2.2.1.0
Creating temp directory C:\Users\vivek\AppData\Local\Temp\aeb9348c-3f99-4537-bed7-7313b3c4bcbe

Warning: Could not load file or assembly 'Microsoft.DiaSymReader.Native.amd64.dll' or one of its dependencies. The module was expected to contain an assembly manifest.


Warning: Could not load file or assembly 'Microsoft.DiaSymReader.Native.x86.dll' or one of its dependencies. The module was expected to contain an assembly manifest.


Warning: Could not load file or assembly 'Microsoft.DiaSymReader.Native.amd64.dll' or one of its dependencies. The module was expected to contain an assembly manifest.


Warning: Could not load file or assembly 'Microsoft.DiaSymReader.Native.x86.dll' or one of its dependencies. The module was expected to contain an assembly manifest.


Error: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.IO.FileLoadException: 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)
   at Microsoft.AspNet.SignalR.DefaultDependencyResolver.RegisterDefaultServices()
   at Microsoft.AspNet.SignalR.DefaultDependencyResolver..ctor()
   --- End of inner exception stack trace ---

Server stack trace:
   at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
   at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
   at System.Activator.CreateInstance(Type type, Boolean nonPublic)
   at System.Activator.CreateInstance(Type type)
   at Microsoft.AspNet.SignalR.Utils.GenerateHubProxyCommand.JavaScriptGenerator.GenerateProxy(String path, String url, Action`1 warning)
   at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs)
   at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg)

Exception rethrown at [0]:
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
   at Microsoft.AspNet.SignalR.Utils.GenerateHubProxyCommand.JavaScriptGenerator.GenerateProxy(String path, String url, Action`1 warning)
   at Microsoft.AspNet.SignalR.Utils.GenerateHubProxyCommand.OutputHubs(String path, String url, String outputPath)
   at Microsoft.AspNet.SignalR.Utils.GenerateHubProxyCommand.Execute(String[] args)
   at Microsoft.AspNet.SignalR.Utils.Program.Main(String[] args)

Also tried:

signalr.exe ghp /assembly:"D:\WORKS\VISUALSTUDIO\ASPWEBSITE\ServerSignalR_ChatHub\ServerSignalR_ChatHub\bin\ServerSignalR_ChatHub.dll"

It generate empty server.js file

What am I doing wrong or missing?

c#
.net
signalr-hub
asked on Stack Overflow Sep 18, 2016 by VKC • edited Sep 18, 2016 by VKC

2 Answers

1

Oh, man.... After lot of research and try I finally found answer. In the error:

It says, Could not load assembly Newtonsoft.Json, Version=6.0.0.0. But I have Version=9.0.0.0 So I just force uninstall it and install it with minimum dependency version=6.0.0.0(In my case it's depended to SignalR.Core.dll (v2.2.1)).

uninstall-package newtonsoft.json -force

install-package newtonsoft.json -version "6.0.4"

and then run:

signalr.exe ghp /path:"D:\WORKS\<path>\ServerSignalR_ChatHub\bin"

And it generate server.js successfully !!

answered on Stack Overflow Sep 19, 2016 by VKC
0

I thought I would add my solution which uses the "pre-build event command line" in Visual Studio under the project properties "Build Events". Instead of playing with the installed packages for my program (which works perfectly fine otherwise), I put a copy of the old NewtonSoft files in an "OldNewton" directory at the Solution Folder level. I noted the install directory for the SignalR.Utils executable files. Then I scripted some commands to change to the bin folder, copy in the old NewtonSoft files and the Utils files, execute the signalR ghp command to create the hub script, then copy the file to where I wanted it. I also added some cleanup commands and some commands to backup/restore any existing NewtonSoft files. You might want to copy the SignalR.Utils files to their own directory next to the OldNewton files in case the package gets updated. I think it looks a lot more complicated than it is. You could remove the echo commands and probably even the backup and cleanup commands to make it much shorter. There are a few ways to accomplish this, but this how I chose to do it.

cd $(TargetDir)
@echo Creating backup
if not exist backup\nul mkdir backup
if exist backup del backup\*.* /q /f
if exist Newton*.* move Newton*.* backup\*.* /q /f 
@Echo Copying in the Signal R files
copy "$(SolutionDir)packages\Microsoft.AspNet.SignalR.Utils.2.4.1\tools\net40" .
@Echo Copying in the old NewtonSoft files
copy $(SolutionDir)OldNewton\*.* .
@Echo Creating the hub script: signalr ghp /path:$(TargetDir)
signalr ghp /path:$(TargetDir)
@Echo moving hub file to where I want it: move /Y server.js "$(ProjectDir)scripts\app\srFreedomHub.js" 
move /Y server.js "$(ProjectDir)scripts\app\srFreedomHub.js" 
@echo remove the signalR util files and old Newton Files
del signalr.* /q /f
del Newton*.* /q /f
@echo Restore the backup folder files
if exist backup\Newton*.* move backup\*.* .
@echo Remove the backup folder
if exist backup\nul rmdir backup /S /Q
answered on Stack Overflow Jul 11, 2020 by K Kimble

User contributions licensed under CC BY-SA 3.0