2016-05-31 123 views
1

我想創建一個套接字服務器,並且遇到了不確定如何解決的問題。缺少對程序集的引用

下面是我在用我的project.json

{ 
    "version": "1.0.0-*", 
    "buildOptions": { 
    "emitEntryPoint": true 
    }, 
    "dependencies": { 
    "Microsoft.NETCore.App": { 
     "type": "platform", 
     "version": "1.0.0-rc2-3002702" 
    }, 
    "vtortola.WebSocketListener": "2.2.0.2" 
    }, 
    "frameworks": { 
    "netcoreapp1.0": { 
     "imports": "net45" 
    } 
    } 
} 

然後我有這個基本的腳本Server.cs

using System.Net; 
using vtortola.WebSockets; 

public class Server { 

    public static void Main(string[] args){ 

     var server = new WebSocketListener(new IPEndPoint(IPAddress.Any, 8006)); 
     var rfc = new vtortola.WebSockets.Rfc6455.WebSocketFactoryRfc6455(server); 
     server.Standards.RegisterStandard(rfc); 
     server.Start(); 

    } 

} 

當我運行下面的命令:

[email protected]:~/Documents/Chat$ dotnet run 

我收到以下錯誤:

Project Chat (.NETCoreApp,Version=v1.0) will be compiled because expected outputs are missing
Compiling Chat for .NETCoreApp,Version=v1.0
/usr/share/dotnet/dotnet compile-csc @/home/master/Documents/Chat/obj/Debug/netcoreapp1.0/dotnet-compile.rsp returned Exit Code 1
/home/master/Documents/Chat/Server.cs(8,26): error CS0012: The type 'IPEndPoint' is defined in an assembly that is not referenced. You must add a reference to assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
/home/master/Documents/Chat/Server.cs(10,26): error CS0012: The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
/home/master/Documents/Chat/Server.cs(11,16): error CS0012: The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

Compilation failed.
0 Warning(s)
3 Error(s)

Time elapsed 00:00:02.6995789

+0

哪裏vtortola.WebSocketListener從組裝。我的猜測:從.NET Framework項目;)。 – Thomas

+0

它來自NuGen –

回答

6

您不能將net45導入netcoreapp1.0,那不起作用。當你指定imports時,你基本上會說:「我知道那些包聲稱它們不兼容,但我保證它們是」。

vtortola.WebSocketListener只支持net45,所以你將不能夠使用它的.Net核心(雖然你仍然可以使用DOTNET CLI中使用它,如果你改變了你的框架,net451)。

但似乎有一個vtortola.WebSocketListener.dnx包的測試版,它支持dnxcore50(以前的預發佈版本的.Net Core)。導入(與portable-net45+win8Microsoft.Tpl.Dataflow依賴項)應該工作。然後project.json看起來就像這樣:

{ 
    "version": "1.0.0-*", 
    "buildOptions": { 
    "emitEntryPoint": true 
    }, 
    "dependencies": { 
    "Microsoft.NETCore.App": { 
     "type": "platform", 
     "version": "1.0.0-rc2-3002702" 
    }, 
    "vtortola.WebSocketListener.dnx": "2.2.0.1-beta-00002" 
    }, 
    "frameworks": { 
    "netcoreapp1.0": { 
     "imports": [ "dnxcore50", "portable-net45+win8" ] 
    } 
    } 
} 

It seems vtortola.WebSocketListener will also support RC2 directly in the future.

+0

太棒了!我能夠無誤地構建項目! –

-1

請導入net451作爲數組元素爲「進口」一節,並插入以下ependency Microsoft.NETCore.Portable.Compatibility: "1.0.1-*