所以,我有一个SignalR自托管控制台应用程序和一个在WAMP上运行的网站.当我localhost用作域名时,一切正常.显然这只适用于本地.
我希望它也适用于其他计算机.所以我试图localhost在c#控制台应用程序和网站上更改为我的本地IP.当我有本地IP时,控制台应用程序崩溃,错误:
mscorlib.dll中发生未处理的"System.Reflection.TargetInvocationException"类型异常
我也尝试使用*而不是localhost在控制台应用程序中.像这样:
string url = "http://*:8080/servers/2/";
Run Code Online (Sandbox Code Playgroud)
它也一样,它崩溃了.我究竟做错了什么?
控制台应用代码:
namespace SignalRSelfHost
{
class Program
{
public static IPAddress ipAd { get; set; }
public static TcpListener myList { get; set; }
static void Main(string[] args)
{
// This will *ONLY* bind to localhost, if you want to bind to all addresses
// use http://*:8080 to bind to all addresses.
// See http://msdn.microsoft.com/en-us/library/system.net.httplistener.aspx
// for more information.
string url = "http://localhost:8080/servers/2/";
using …Run Code Online (Sandbox Code Playgroud)