2013-11-28 19 views
11

Tôi mới sử dụng tín hiệu r và tôi đang cố gắng tạo ứng dụng trò chuyện cơ bản trong C# visual studio 2012 nhưng tôi nhận được lỗi sau.Lỗi trong studio trực quan lớp khởi động nợ 2012

The following errors occurred while attempting to load the app. 
- No assembly found containing an OwinStartupAttribute. 
- The discovered startup type 'SignalRTutorials.Startup, SignalRTutorials, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' 
    conflicts with the type 'Microsoft.VisualStudio.Web.PageInspector.Runtime.Startup, Microsoft.VisualStudio.Web.PageInspector.Runtime, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. 
Remove or rename one of the types, or reference the desired type directly. 
To disable OWIN startup discovery, add the appSetting owin:AutomaticAppStartup with a value of "false" in your web.config. 
To specify the OWIN startup Assembly, Class, or Method, add the appSetting owin:AppStartup with the fully qualified startup class or configuration method name in your web.config. 

Tôi đã tạo ra 3 file:

1) đầu tiên là lớp Letschat.cs như:

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Web; 
using Microsoft.AspNet.SignalR; 
using Microsoft.AspNet.SignalR.Hubs; 
namespace SignalRTutorials 
{ 
    [HubName("myChatHub")] 
    public class LetsChat:Hub 
    { 
     public void send(string message) 
     { 

      Clients.All.addMessage(message); 

     } 
    } 
} 

2) thứ hai tập tin chat.aspx như

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Chat.aspx.cs" Inherits="SignalRTutorials.Chat" %> 

<!DOCTYPE html> 

<html xmlns="http://www.w3.org/1999/xhtml"> 
<head runat="server"> 
    <title></title> 
    <script src="Scripts/jquery-1.6.4.min.js"></script> 
    <script src="Scripts/jquery-1.6.4-vsdoc.js"></script> 
    <script src="Scripts/jquery-1.6.4.min.js"></script> 
    <script src="Scripts/jquery.signalR-2.0.0.js"></script> 
    <script src="Scripts/jquery.signalR-2.0.0.min.js"></script> 
</head> 
<body> 
    <form id="form1" runat="server"> 
     <script type="text/javascript"> 

      $(function() 
      { 
       var IWannaChat=$.connection.myChatHub; 
       IWannaChat.client.addMessage=function(message){ 

        $('#listMessages').append('<li>'+message+'</li>'); 
       }; 
       $("#SendMessage").click(function(){ 
        IWannaChat.server.send($('#txtMessage').val()); 
       }); 
       $.connection.hub.start(); 
      }); 


     </script> 
    <div> 
    <input type="text" id="txtMessage" /> 
     <input type="text" id="SendMessage" value="broadcast" /> 
     <ul id="listMessages"> 



     </ul> 
    </div> 
    </form> 
</body> 
</html> 

3) class Được đặt tên là Startup.cs

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Net; 
using System.Threading.Tasks; 
using System.Web; 
using System.Web.Routing; 
using Microsoft.AspNet.SignalR; 
using Microsoft.Owin.Security; 
using Owin; 


namespace SignalRTutorials 
{ 
    public class Startup 
    { 
     public void Configuration(IAppBuilder app) 
     { 
      app.MapSignalR(); 
     } 

    } 
} 

Tôi không biết nơi tôi đang làm sai bất kỳ sự giúp đỡ trong lĩnh vực này sẽ được đánh giá cao.

+0

gì phiên bản của .NET và SignalR bạn đang sử dụng? – nphx

+0

. Studio 4.5 trực quan 4.5 và tín hiệu r 2.0 –

+3

Bạn có thể thử thêm thuộc tính mức assembly không [assembly: OwinStartup (typeof (SignalRTutorials.Startup))] để xem có giải quyết được vấn đề không? – Praburaj

Trả lời

14

Đang đối mặt với cùng một vấn đề. Đã cố gắng thêm thuộc tính mức lắp ráp, như được đề xuất bởi @Praburaj

Bạn có thể thử cách sau.

using Microsoft.AspNet.SignalR; 
using Microsoft.Owin.Security; 
using Owin; 

//add the attribute here 
[assembly: OwinStartup(typeof(SignalRTutorials.Startup))] 

namespace SignalRTutorials 
{ 
    public class Startup 
    { 
     public void Configuration(IAppBuilder app) 
     { 
      app.MapSignalR(); 
     } 

    } 
} 
6

tôi đã cùng một vấn đề nhưng trên Visual Studio 2013.

Loại bỏ các \ bin\ obj thư mục trên dự án của tôi sau đó xây dựng lại nó cố định vấn đề.

2

Bạn chỉ cần thêm lớp OWIN StartUp [tức là StartUp1.cs] vào dự án của bạn.

using System; 
using System.Threading.Tasks; 
using Microsoft.Owin; 
using Owin; 

[assembly: OwinStartup(typeof(UserInterfaceLayer.Hubs.Startup))] 

namespace UserInterfaceLayer.Hubs 
{ 
    public class Startup 
    { 
     public void Configuration(IAppBuilder app) 
     { 
      app.MapSignalR(); 
     } 
    } 
} 
0

Nếu bạn đã xây dựng dự án của mình và đổi tên thành dự án, sự cố này có thể xảy ra. Hãy thử xóa tất cả các tệp trong thư mục bin và sau đó chạy dự án của bạn. Điều này làm việc cho tôi.

Các vấn đề liên quan