xSocket WebRTC Sample error - asp.net

Hi i have a problem i have a aplication that i m desenvolving an its the same princepel like facebook like a social engine in mvc 4 i am trying to put video-conference i already tried in a empty asp.net mvc4 empty internet application and it works xSocket.net WebRTC Sample so where is my error
so i followed the steps PM> Install-Package XSockets.Sample.WebRTC
1: Add a new XSockets.Web.Bootstrapper (ctrl+shift+a)
2: Under the "Web" tab go to the "Servers" section and set Use Visual Studio Development Server
using System.Web;
using XSockets.Core.Common.Socket;
[assembly: PreApplicationStartMethod(typeof(basicWebRTC.XSocketsWebBootstrapper1), "Start")]
namespace basicWebRTC
{
public static class XSocketsWebBootstrapper1
{
private static IXSocketServerContainer wss;
public static void Start()
{
wss = XSockets.Plugin.Framework.Composable.GetExport<IXSocketServerContainer>(); // when e start An exception of type 'XSockets.Plugin.Framework.Exceptions.ExportException' occurred in XSockets.Plugin.Framework.dll but was not handled in user code //
wss.StartServers();
}
}
}

Related

Can't get access to the Events in Visual Studio Community Toolkit

I'm trying to migrate my old Visual Studio extension to the new 2022 Studio. Found some fancy solution named 'Community Visual Studio Toolkit', but got some issues. When I use the ProvideAutoLoad attribute for loading my extension when a user opens some solution, I can't get access to the WindowEvents which I need to sign my event handlers. This is the error on debugging: https://snipboard.io/yUXIed.jpg
So this is the code I use, and here I have the error:
[ProvideAutoLoad(UIContextGuids80.NoSolution, PackageAutoLoadFlags.BackgroundLoad)]
public sealed class MyPackage : ToolkitPackage
{
protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress<ServiceProgressData> progress)
{
await this.RegisterCommandsAsync();
VS.Events.WindowEvents.ActiveFrameChanged += WindowEvents_ActiveFrameChanged;
}
}
And the thing is my old implementation works with this code:
[ProvideAutoLoad(UIContextGuids80.NoSolution, PackageAutoLoadFlags.BackgroundLoad)]
public sealed class MyPackage : ToolkitPackage
{
protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress<ServiceProgressData> progress)
{
await this.RegisterCommandsAsync();
// Getting `DTE2 dte` trough standard way...
dte.Events.WindowEvents.WindowActivated += WindowEvents_WindowActivated;
}
}
But I don't want to use old kinds of code in the new extension version, so, how to fix this issue in first example of implementation?
Well, I'm not sure about the "perfection" of this solution, but with this line of code added before access to the events - it works.
await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);
Seems like you have to be in main thread to access these events.

.NET Core Error 1053 the service did not respond to the start or control request in a timely fashion

I created a Windows Service starting from my .NET Core project following this
After this, I installed correctly it on my working machine and started it.
This is my service class:
using System;
using System.Diagnostics;
using System.ServiceProcess;
using System.Threading.Tasks;
namespace xxx
{
public class WindowsService
{
static void Main(string[] args)
{
System.IO.Directory.SetCurrentDirectory(System.AppDomain.CurrentDomain.BaseDirectory);
using (var service = new Service())
{
ServiceBase.Run(service);
}
}
}
internal class Service : ServiceBase
{
public Service()
{
ServiceName = "...";
}
protected override void OnStart(string[] args)
{
try
{
base.OnStart(args);
Task.Run(() => xxxx);
}
catch (Exception ex)
{
EventLog.WriteEntry("Application", ex.ToString(), EventLogEntryType.Error);
}
}
protected override void OnStop()
{
base.OnStop();
}
protected override void OnPause()
{
base.OnPause();
}
}
}
So, I copied the file and installed it also on a server. Here, when I try to start it, I get:
After this, I start a lot of googling... for example, I tried the following steps :
Go to Start > Run > and type regedit
Navigate to: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control
With the control folder selected, right click in the pane on the right and - select new DWORD Value
Name the new DWORD: ServicesPipeTimeout
Right-click ServicesPipeTimeout, and then click Modify
Click Decimal, type '180000', and then click OK
Restart the computer
The weird point here is that the voice ServicesPipeTimeout didn't exist and I created it. Comparing the server with my working machine, there are also other value not present in the server. They are:
ServicesPipeTimeout
OsBootstatPath
Here the screenshot of regedit from the server:
Are these relevant?
I also tried to reinstall the service, recompile my files... how can I fix this problem? The error appears immediatly, it doesn't wait any timeout!
I had this problem when I switched my project to another location.
When I moved the project, I had copied the files in bin/debug folder too. The issue was resolved after I cleared the debug folder and created a new build.
See if this works!
It's a bit old question but someone may find this useful.
So I had the following code in Program.cs:
builder.SetBasePath(Environment.CurrentDirectory).AddJsonFile("appsettings.json")
Changed it to:
builder.SetBasePath(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)).AddJsonFile("appsettings.json")
This seemed to fix the problem for me.
The problem with this error is that it is super generic.
Hopefully MS will give us some log in the future.
if you check the windows event viewer under applications it tells you what exactly is the exception that causes this error.
in my case the problem was i published the service in net6 and tried to run it on a pc with net7 installed. apparently it requires the exact major version that was used to publish the app.

Add Model Project (EntityFramwork) to Asp.net Core 3 Project

I have 3 projects in my Solution like below:
ModelProject (EntityFramework)
ProjectA (ASP.NET MVC)
ProjectB (ASP.NET CORE 3 with Blazor)
So in model project i defined my tables ,relations, queries and their classes then added that on ProjectA and ProjectB.
on ProjectB (.net core) in startup.cs by services.AddDbContext tries to add dbcontext (ModelProject) but get this error:
Cannot convert lambda expression to type 'ServiceLifetime' because it is not a delegate type
Is this error for using EF on Core Project? how can i solve it?
ProjectB (Core):
services .AddEntityFrameworkSqlServer() .AddDbContext<Models.DataContext>(options => { options.UseSqlServer(Configuration.GetConnectionString("DataContext")); });
and dbcontext (EntityFramework Standard):
namespace ModelProject
{
public class DataContext : DbContext
{
public DataContext() : base("DataContext")
{
Database.SetInitializer(new MigrateDatabaseToLatestVersion<DataContext, Migrations.Configuration>());
(this as IObjectContextAdapter).ObjectContext.ContextOptions.UseCSharpNullComparisonBehavior = true;
((IObjectContextAdapter)this).ObjectContext.CommandTimeout = 300;
}
}
}
It needs to be:
.AddDbContext<Models.DataContext>(options =>
options.UseSqlServer(Configuration.GetConnectionString("DataContext")));
In other words, without the curly brackets. You could alternatively just return the options instance, but that's all just unnecessary code-bloat. The exception is a red herring. Because your lambda currently is essentially an action (no return) rather than a func, it's not matching the right param for AddDbContext.

Unit Test Project: "No connection string could be found in the application config file"

I had an existing MVC5 web app. I just created a new Unit Test Project and added the following code....
using Microsoft.VisualStudio.TestTools.UnitTesting;
using SomethingApp.Services;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SUT = SomethingApp.Services.ReportingServices; // SUT = System Under Test
namespace SomethingApp.Services.Tests
{
[TestClass]
public class GettingScoreForQuestionShould
{
[TestMethod]
public void ReturnScoreWhenGivenValidData()
{
// Arrange
int eventId = 39;
int questionId = 271;
decimal score;
// Act
score = SUT.GetScoreForQuestion(eventId, questionId);
// Assert
Assert.AreEqual("80",score);
}
}
}
When the method GetScoreForQuestion runs in the normal web app it runs perfect. But, when I run it through the test method I'm getting this error...
Message: Test method SomethingApp.Services.Tests.GettingScoreForQuestionShould.ReturnScoreWhenGivenValidData
threw exception: System.InvalidOperationException: No connection string
named 'myDbContext' could be found in the application config file.
The error is, of course, coming from the method GetScoreForQuestion, which works fine in the normal web app.
I don't understand why I need to add an application config file and this config connection string to the test project. Seems like, since I'm calling the method in the MVC project, that this has the responsibility of making the connection and doing it's thing (which it's doing in the normal course of the app). Am I mistaking something?
And, I tried adding a new application.config file and the connection string to the unit test project, but then the test method won't show up anymore in the Test Explorer after build. Any suggestions? Thanks!
UPDATE ****
Here's the code for GetScoreForQuestion (the offending method, which works in the web app fine, but not when called thru the test method)....
public static decimal GetScoreForQuestion(int eventId, int ThingyQuestionId)
{
// the following line fails with the connection issue
var ThingyResults = Db.ThingyResults.Where(e => e.EventId == eventId && e.ThingyQuestionId == ThingyQuestionId)
.AsNoTracking().ToList();
:
:
:
}
Db is declared in the same class as...
public static class ReportingServices
{
private static readonly ThingyContext Db = new ThingyContext();
When you are executing a unittest, that project is your running application. So that is where the configuration file is read from. And note that you need an app.config, not a web.config.
It looks like you may be creating a new ThingyContext within your ReportingServices class. Look into injecting an Interface so that you can substitute a mock implementation for testing purposes.
Here's some links to help get you started:
https://romiller.com/2012/02/14/testing-with-a-fake-dbcontext/
https://ardalis.com/new-is-glue

SignalR, Owin do not work after VS2015 move and package updates

I recently upgraded to VS2015 (did not remove VS2013 or 2010). NuGet did not instal properly. While the project ran it loaded with streaming messages re package updating. I just removed and reinstalled NuGet and updated all packages.
Now I have 2 problems that could be related.
1) 134 errors. Everything to do with SignalR and Owin is failing with messages like:
'type or namespace 'Hub' could not be found'.
Here is the key code. Other Usings were greyed out as unnecessary, and are removed.
using System;
namespace SignalR
{
[Microsoft.SignalR.HubName("SeekerHub")]
public class SeekerHub : Hub
{
private static Decimal number;
public static void SendMessage(string message)
{
//StartTimer();
//var callingClient = Context.ConnectionId;
var hubContext = GlobalHost.ConnectionManager.GetHubContext<SeekerHub>();
if (Decimal.TryParse(message, out number))
{
if (number == 0)
{ }
hubContext.Clients.All.receiveUpdate(message);
}
else
hubContext.Clients.All.receiveNotification(message);
}
}
}
2) 6 warnings that relate to updating. All relate to the same SignalR/Owin area but the message suggests that it is looking in the VS2013/localhost xyz/ file and not in the VS2015 file. Is there a way I can change the pointer when the package looks to update itself?
Thanks, in advance, for any help.

Resources