简体   繁体   中英

Error in owin startup class visual studio 2012

I am new to signal r and I am trying to create a basic chat application in c# visual studio 2012 but i am getting following error.

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.

I have created 3 files:

1) first is Letschat.cs class as:

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) second file chat.aspx as

<%@ 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 Named as 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();
        }

    }
}

I dont know where i am doing wrong any help in this regard will be appreciated.

Was facing the same problem. Tried adding assembly level attribute, as suggested by @Praburaj

You can try the following.

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

    }
}

I had the same problem but on Visual Studio 2013.

Removing the \\bin and \\obj folders on my project then rebuilding it fixed the problem.

You just need to add OWIN StartUp class [ie StartUp1.cs] into your project.

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

If you have built your project, and then renamed it, this issue might occur. Try delete all the files in the bin folder and then run your project. This worked for me.

Just add this line

[assembly: OwinStartup(typeof(SignalRTutorials.Hubs.Startup))] as described here

http://yazilimsozluk.com/no-assembly-found-containing-an-owinstartupattribute

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM