Error
'Owin.IAppBuilder' does not contain a definition for 'MapSignalR' and
no extension method 'MapSignalR' accepting a first argument of type
'Owin.IAppBuilder' could be found (are you missing a using directive
or an assembly reference?)
Code
using Microsoft.Owin;
using Owin;
[assembly: OwinStartup(typeof(SignalRChat.Startup))]
namespace SignalRChat
{
public class Startup
{
public void Configuration(IAppBuilder app)
{
// Any connection or hub wire up and configuration should go here
app.MapSignalR();
}
}
}
Any help would be greatly appreciated...
Update
signalR version 2.0.3
Microsoft Owin version 2.0.2
Owin version 1.0.0
Visual Studio 2012
Only install this nuget:
Install-Package Microsoft.AspNet.WebApi.OwinSelfHost
Finally was able to solve it by adding signalR dependencies before adding signalR from NuGet Packages
Step's I followed:
Added Microsoft.Owin //version 2.0.1
Added Microsoft.Owin.Security //version 2.0.1
Added Microsoft Asp.Net SignalR
The reason I discovered was a problem with version 2.0.2 of Microsoft.Owin and Microsoft.Owin.Security and then adding a class named Startup.cs with following code:
using Microsoft.Owin;
using Owin;
[assembly: OwinStartup(typeof(webApp.Startup))]
namespace webApp
{
public static class Startup
{
public static void Configuration(IAppBuilder app)
{
app.MapSignalR();
}
}
}
Directly adding Microsoft Asp.Net SignalR from NuGet adds version 2.0.2 of Microsoft.Owin and Microsoft.Owin.Security which creates the problem.
Hope it helps someone...!!
Update-Package Owin -Reinstall
worked for me
Install Nuget Package: Microsoft.AspNet.Identity.Owin
I had this same problem. Turns out my .csproj file the first line:
Project ToolsVersion="12.0" didn't match my other files. Changed it to:
Project ToolsVersion="14.0"
and no more compile issue.
Using MVC5, enter your Startup.cs file.
Add IAppBuilder appBuilder to Configure():
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, IAppBuilder appBuilder)
{
Then, under
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
add appBuilder.MapSignalR();
Asp.Net 5 empty mvc project out of the box creates something that looks like this
using Microsoft.Owin;
using Owin;
namespace DeadlyChat
{
public class Startup
{
// For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=398940
public void ConfigureServices(IServiceCollection services)
{
}
public void Configure(IApplicationBuilder app)
{
app.MapSignalR();
}
}
}
Took me a while to notice that Configure was supposed to be Configuration and IApplicationBuilder needs to be IAppBuilder. I also pulled off the assembly annotation above the namespace.
I wound up scrapping trying to use Asp.Net 5 couldn't get it to work. Went back to 4.6 and everything worked fine. Followed this walkthrough http://www.asp.net/signalr/overview/getting-started/tutorial-getting-started-with-signalr
Related
I've updated my project from .net core 2.1 to 2.2 and then logging.AddAzureWebAppDiagnostics() in Program.cs no longer works.
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.ConfigureLogging((hostingContext, logging) =>
{
logging.AddAzureWebAppDiagnostics();
})
.UseStartup<Startup>()
.Build();
}
'ILoggingBuilder' does not contain a definition for 'AddAzureWebAppDiagnostics' and no accessible extension method 'AddAzureWebAppDiagnostics' accepting a first argument of type 'ILoggingBuilder' could be found (are you missing a using directive or an assembly reference?
Referring to this document,
If targeting .NET Framework or referencing the Microsoft.AspNetCore.App metapackage, add the provider package to the project. Invoke AddAzureWebAppDiagnostics on an ILoggerFactory instance:
So the way might be slightly different from the previous one. How do I fix this issue?
The documentation is a bit tricky but if read carefully it become clear that following steps should be undertaken (for NET Core):
Microsoft.Extensions.Logging.AzureAppServices should be installed
There is NO need to call logging.AddAzureWebAppDiagnostics();
Logging can be configured using following code
// file startup.cs
using Microsoft.Extensions.Logging.AzureAppServices;
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
//...
services.Configure<AzureFileLoggerOptions>(Configuration.GetSection("AzureLogging"));
}
}
File appsettings.json should contain
"AzureLogging": {
"FileName" : "azure-diagnostics-",
"FileSizeLimit": 50024,
"RetainedFileCountLimit": 5
}
Logging should be turned on on Azure Portal. After enabling, Azure Portal may ask for installing addon. Message requiring to install addon will appear on logging config page.
Call logger.LogWarning ("message"); in your code to write to log file. If you use LogWarning be sure to set Level to Warning or more detailed (Info or Debug)
Trying to build ReactJS.NET in Visual Studio 2015
using Microsoft.AspNetCore.Http;
using JavaScriptEngineSwitcher.Core;
using JavaScriptEngineSwitcher.ChakraCore;
using React.AspNet;
In ConfigureServices
public void ConfigureServices(IServiceCollection services)
{
// Add framework services.
services.AddApplicationInsightsTelemetry(Configuration);
services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
services.AddReact();
services.AddJsEngineSwitcher(options => options.DefaultEngineName = ChakraCoreJsEngine.EngineName)
.AddChakraCore();
services.AddMvc();
}
Got an Error to this part:
AddJsEngineSwitcher
IServiceCollection does not contain definition for AddJsEngineSwitcher
Trying to fix some solutions but got no luck.
Checking also my Reference
JavaScriptEngineSwitcher 3.0.0 is exists.
Also searching in Nuget package and changed JavaScriptEngineSwitcher but still the same.
I am using .NET Framework 4.6.
The docs show that you need to install this NuGet package, which contains the AddJsEngineSwitcher extension method that's missing:
JavaScriptEngineSwitcher.Extensions.MsDependencyInjection
Once installed, you'll also need to add the following using to include the namespace:
using JavaScriptEngineSwitcher.Extensions.MsDependencyInjection;
I am trying to install steam login, for my website, BUT after i have done the installation in nuget package manager console, with the following install code: Install-Package Owin.Security.Providers.Steam I am missing my Startup.Auth.cs. What am i doing wrong?
The project is started without "Individual User Accounts".
The Startup.Auth.cs file should be in your App_Start Folder. Just create a default MVC web application with Individual User Accounts selected as the Authentication type under Change Authentication option to see how its implemented.
For reference:
using Microsoft.Owin;
using Microsoft.Owin.Security.Cookies;
using Owin;
using Owin.Security.Providers.Steam;
namespace WebApplication
{
public partial class Startup
{
public void ConfigureAuth(IAppBuilder app)
{
//other Config
app.UseSteamAuthentication("your API key");
}
}
}
See here for reference on how to add the Steam login button.
Edit:
Also see here for Adding MVC 5 Identity to our Existing Project.
You may need to add startup.cs to root of your project:
using Microsoft.Owin;
using Owin;
[assembly: OwinStartupAttribute(typeof(WebApplication1.Startup))]
namespace WebApplication1
{
public partial class Startup
{
public void Configuration(IAppBuilder app)
{
ConfigureAuth(app);
}
}
}
Error
The type or namespace name 'OwinStartupAttribute' could not be found
The type or namespace name 'OwinStartup' could not be found
Code
using Microsoft.Owin;
using Owin;
[assembly: OwinStartup(typeof(Employee.Web.Models.Startup))]
namespace Employee.Web.Models.Startup
{
public class Startup
{
public void Configuration(IAppBuilder app)
{
app.MapSignalR();
}
}
}
Any help would be appreciated.
Using:
.net 4.0
MVC 4
Microsoft.AspNet.SignalR.SystemWeb (1.1.0.0)
Microsoft.Owin (2.1.0.0)
Microsoft.Owin.Host.SystemWeb (2.1.0.0)
Owin (1.0.0.0)
Visual Studio 2013
Installed singlar after Referencing Microsoft.Owin using the command Install-Package Microsoft.AspNet.SignalR -Version 1.1.3
UPDATE:
I removed [assembly:..
and also added this in web.config:
<add key="owin:AppStartup" value="Employee.Web.Models.Startup" />
The error now says
'Owin.IAppBuilder' does not contain a definition for 'MapSignalR' and no extension method 'MapSignalR' accepting a first argument of type 'Owin.IAppBuilder' could be found
To fix that:
Make sure that Microsoft.Owin is installed
Right-click on the
project and click add item and search for "startup"
Now, you already have an OWIN Startup.cs class. click on OWIN Startup
class and just add it under Startup1.cs then the error will be
gone.
Delete the added Startup1.cs
finally, rebuild.
Hope that helps!
Create One Class With Name Startup this will help you..
public class Startup
{
public void Configuration(IAppBuilder app)
{
app.MapSignalR();
}
}
In addition to this, if your startup class is somehow not in your default name space, add a web config line to the area like:
<add key="owin:AppStartup" value="[NameSpace].Startup" />
Here is more explenation.
I removed Microsoft.Owin from my project's references
downloaded the .dll and placed it into the project's bin/ folder
Right clicked references, add, browse, find the .dll, it builds!
Make sure the packages.config version of Owin matches your downloaded version.
I am trying to publish an app in the web but the server searches for Global.asax.cs and I deleted that file and added startup.cs instead.
How can I make the server search for startup.cs instead of Global.asax.cs, or what is the best approach to fix this issue ?
You have to add the Owin package from Nuget and use a startup class looks like this:
using Owin;
using Microsoft.Owin;
[assembly: OwinStartup(typeof(YOURNAMESPACE.Startup))]
namespace YOURNAMESPACE
{
public class Startup
{
public void Configuration(IAppBuilder app)
{
//DO your stuff
}
}
}
Hope this helps