Hangfire Error on startup - owin

I had hangfire working well for sometime and then I tried to rollback to a previous version that supported .net 4.5.1 and then I went back to .net 4.6.1 and re-upgraded hangfire to 1.6.14 with Owin 3.1. I've reset all my code/nuget references, etc to 1.6.14 and deleted all of the tables so it would recreate them and I'm still getting this error:
'hangfire.dashboard.dashboardmiddleware' does not have a constructor taking 5 arguments.
I'm using owin 3.1 and this happens when using this code:
[assembly: OwinStartup(typeof(MyWebApplication.Startup))]
namespace MyWebApplication
{
public class Startup
{
public void Configuration(IAppBuilder app)
{
app.UseHangfire(config =>
{
config.UseSqlServerStorage(ConfigurationManager.ConnectionStrings["QueueConnection"].ConnectionString);
config.UseServer();
});
}
any ideas?

Try to use hangfire like this:
JobStorage.Current = new SqlServerStorage(constr);
app.UseHangfireDashboard();
app.UseHangfireServer();

You can use:
var options = new BackgroundJobServerOptions { WorkerCount = Environment.ProcessorCount * 5 };
app.UseHangfireServer(options);

Related

How can I lock the window size of a .NET MAUI app?

I need a solution for locking the window size of a .NET MAUI app. I don't want to allow users to change the app's height and width.(For Windows app)
This can be achieved by using WinUIEx package for the Windows.
Step 1:Install WinUIEx NuGet package.
Step 2:Update Maui.Program.cs to set your initial window size and position.
using Microsoft.Maui.LifecycleEvents;
#if WINDOWS
using WinUIEx;
#endif
namespace MauiApp01;
public static class MauiProgram
{
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
.ConfigureFonts(fonts =>
{
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
});
#if WINDOWS
builder.ConfigureLifecycleEvents(events =>
{
events.AddWindows(wndLifeCycleBuilder =>
{
wndLifeCycleBuilder.OnWindowCreated(window =>
{
//Set size and center on screen using WinUIEx extension method
window.CenterOnScreen(1920,1080);
});
});
});
#endif
return builder.Build();
}
}
Reference link.

Phaser 3 ScaleManager exception

I am trying to enable fullscreen in my game written in Phaser 3.
I am doing it from Scene class via
this.game.scale.startFullScreen();
but getting error in f12 browser console
Uncaught TypeError: this.game.scale.startFullScreen is not a function
at TitleScene.<anonymous> (TitleScene.js:23)
at InputPlugin.emit (phaser.js:2025)
at InputPlugin.processDownEvents (phaser.js:167273)
...
In docs ScaleManager class has startFullScreen method.
Why console tells me it doesn't?
This is the full code of TitleScene.js:
export class TitleScene extends Phaser.Scene {
constructor ()
{
const config =
{
key: 'TitleScene'
}
super(config);
}
preload ()
{
this.load.image('Title', 'assets/Title.png');
}
create ()
{
this.background = this.add.image(960, 540, 'Title');
this.input.manager.enabled = true;
this.input.once('pointerdown', function () {
this.scene.start('MainScene');
this.game.scale.startFullScreen(); // here is the error
}, this);
}
}
There are two problems prevented me from resolving this problem:
I followed examples from here
https://www.phaser.io/examples/v2
But I am using the third version Phaser. And everyone who uses the same must follow examples from here
https://www.phaser.io/examples/v3
You must pay attention to url while using their site with examples. Both pages are the same from the first look. But urls are different. Also there are warning after each example using the second (old) version of engine.
And finally this function name is not startFullScreen but startFullscreen :)

iOS8: backgroundSessionConfiguration is deprecated

Before the iOS8 will be released, I downloaded iOS8 SDK to watch how my application will be work. Sometimes my app need to download data from server and I use NSUrlSession for it. And now, when app preparing session for downloading, appears the next warning:
+backgroundSessionConfiguration: is deprecated. Please use +backgroundSessionConfigurationWithIdentifier: instead.
After it my app crashes with the next exception:
Unable to cast object of type 'MonoTouch.Foundation.NSUrlSessionTask' (Objective-C type: '__NSCFBackgroundDownloadTask') to type 'MonoTouch.Foundation.NSUrlSessionDownloadTask'.
Additional information:
Selector: URLSession:downloadTask:didFinishDownloadingToURL:
Method: Microsoft.Synchronization.ClientServices.NSUrlDownloadDelegate:DidFinishDownloading (MonoTouch.Foundation.NSUrlSession,MonoTouch.Foundation.NSUrlSessionDownloadTask,MonoTouch.Foundation.NSUrl)
Code for creating NSUrlSession:
NSUrlSessionConfiguration sessionConfiguration = NSUrlSessionConfiguration.BackgroundSessionConfiguration(urlSessioinId);
NSUrlDownloadDelegate downloadDelegate = new NSUrlDownloadDelegate();
NSUrlSession downloadSession = NSUrlSession.FromConfiguration(sessionConfiguration, downloadDelegate, new NSOperationQueue());
Thanks for any help!
I have use following to solve this error in Objective-C :
NSURLSessionConfiguration *sessionConfig;
if ([[[UIDevice currentDevice] systemVersion] floatValue] >=8.0f)
{
sessionConfig =[NSURLSessionConfiguration backgroundSessionConfigurationWithIdentifier:#"downloads"];
}
else
{
sessionConfig = [NSURLSessionConfiguration backgroundSessionConfiguration:#"downloads"];
}
This should work.
if(UIDevice.CurrentDevice.CheckSystemVersion(8, 0))
{
configDownload = NSUrlSessionConfiguration.CreateBackgroundSessionConfiguration(sessionId);
}
else
{
configDownload = NSUrlSessionConfiguration.BackgroundSessionConfiguration(sessionId);
}

Error.getStackTrace() returns a string unparseable in flashdevelop?

Accessing a string created by an Error's getStackTrace function is resulting in very unusual behaviour in the FlashDevelop IDE.
package
{
import flash.display.Sprite;
public class Main extends Sprite
{
public function Main():void
{
print("Start");
var err:Error = new Error();
var stack:String = err.getStackTrace();
print(stack);
// also occurs when this is replaced with stack.length or stack[0]
print("End");
}
private function print(input:*):void
{
trace(input);
trace("---");
}
}
}
When run in flash CS4 that outputs
Start
---
Error
at Main()
---
End
---
But when run in FlashDevelop (replacing trace() with FlashConnect.trace()) it outputs
Start
---
Is that a bug, or is it FlashDevelop handling errors in a different way intentionally?
If it is the latter is there a workaround to access the stacktrace of an error?
I managed to fix this by switching to using a dubugging version of the flash player, i hope this helps anyone else with this problem.
instructions for specifying a debug player
Make sure you are compiling in Debug configuration and you may have to enable (set True) "Verbose Stack Trace" in your Project Properties > Compiler Options

Playing wav/mp3 from Windows 7 service

I need to play a sound file (wav or mp3 is fine) from a service in Windows 7/2008... the way we did it in WinXP doesn't work anymore. I've followed this question Play wave file from a Windows Service (C#) with no success, in various combinations. The sound plays fine through the debugger but once I install it as a service it doesn't play, and event logs prove the call is being made. I've also followed the http://bresleveloper.blogspot.co.il/2012/06/c-service-play-sound-with-naudio.html link with the same result.
Code snippet follows below. It is a C# service with VS 2010, .Net 4.0, NAudio 1.5.4.0. I am using
InstallUtil to install/remove the service.
WRT the code, I comment out the Wav or MP3 stuff and one of the methods each time... they all play the sound sucessfully.
static class Program
{
[DllImport("kernel32.dll")]
public static extern Boolean AllocConsole();
static void Main(string[] args)
{
m_eventLog = new EventLog();
m_eventLog.Source = "EventLoggerSource";
if(args.Length > 0 && args[0].ToLower() == "/console")
{
AllocConsole();
EventLoggerApp app = new EventLoggerApp();
app.Start();
m_eventLog.WriteEntry("INFO (Calling Player)");
string fileFullPath=#"c:\aaasound\bunny_troubles.wav",fileFullPath2=#"c:\aaasound\dreams.mp3";
// Wav file
IWavePlayer wavePlayer=new WaveOutEvent(); // Method 1
IWavePlayer wavePlayer=new WasapiOut(NAudio.CoreAudioApi.AudioClientShareMode.Shared,false,100); // Method 2
AudioFileReader audioFile=new AudioFileReader(fileFullPath);
audioFile.Volume = (float)1.0;
wavePlayer.Init(audioFile);
// MP3 file
IWavePlayer wavePlayer=new WasapiOut(NAudio.CoreAudioApi.AudioClientShareMode.Shared,true,100); // Method 1- EventSync/not both work
IWavePlayer wavePlayer=new WasapiOut(NAudio.CoreAudioApi.AudioClientShareMode.Exclusive,false,100); // Method 2- EventSync must be false or throws an exception
WaveStream mp3Reader = new Mp3FileReader(fileFullPath2);
WaveChannel32 inputStream=new WaveChannel32(mp3Reader);
WaveStream wavStream=new WaveChannel32(inputStream);
wavePlayer.Init(wavStream);
//this.wavePlayer.PlaybackStopped += new EventHandler(wavePlayer_PlaybackStopped);
wavePlayer.Play();
while(wavePlayer.PlaybackState == PlaybackState.Playing)
{
Thread.Sleep(100);
}

Resources