Подтвердить что ты не робот

Ошибка в owin startup class visual studio 2012

Я новичок в сигнале r, и я пытаюсь создать базовое приложение чата в visual studio 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.

Я создал 3 файла:

1) сначала класс Letschat.cs как:

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) второй файл chat.aspx как

<%@ 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) класс, названный как 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();
        }

    }
}

Я не знаю, где я делаю неправильно, любая помощь в этом отношении будет оценена.

4b9b3361

Ответ 1

Возникла та же проблема. Попробовал добавить атрибут уровня сборки, как это предложил @Praburaj

Вы можете попробовать следующее.

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();
        }

    }
}

Ответ 2

У меня была та же проблема, но на Visual Studio 2013.

Удаление папок \bin и \obj в моем проекте, а затем восстановление его устранило проблему.

Ответ 3

Вам просто нужно добавить класс OWIN StartUp [i.e. StartUp1.cs] в ваш проект.

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();
        }
    }
}

Ответ 4

Если вы создали свой проект и затем переименовали его, эта проблема может возникнуть. Попробуйте удалить все файлы в папке bin, а затем запустите проект. Это сработало для меня.