Hangfire MySqlStorage - HttpConfiguration does not contain a definition for 'UseStorage' - mysql

I'm trying to use Hangfire MySqlStorage in Web API app with mysql DB. I installed NuGet package "Hangfire.MySqlStorage" version 1.0.3. When I'm configuring Hangfire I'm getting following error,
HttpConfiguration does not contain a definition for 'UseStorage' and
no extension method 'UseStorage' accepting a first argument of type
'HttpConfiguration' could be found (are you missing a using directive or an assembly reference?)
Seems I'm missing a reference here. Could not figure out.

It seems you are calling the method on the wrong object.
It should be, as per the documentation:
GlobalConfiguration.Configuration.UseStorage(
new MySqlStorage(connectionString));
Where GlobalConfiguration is actually Hangfire.GlobalConfiguration from the Hangfire.Core library.

Related

Library class doesn't know of ConfigureWebHostDefaults extension method

I'm building a suite of REST micro-services using .Net Core 3.0 Preview 6. All these services will have the same start up logic. So, I'm trying to place all the code in a .Net Standard library.
The goal is to have the IHostBuilder:CreateHostBuilder method, as well as the Startup:Configure and Startup:ConfigureServices class and methods in the library. The library will also contain error handling logic, customized http response messages, etc.
However, I can't seem to find the correct package that contains the ConfigureWebHostDefaults method. I tried adding the Microsoft.AspNetCore package 2.2.0, but that didn't resolve the issue.
I added the Microsoft.Extensions.Hosting (3.0.0-preview-6) package, that also doesn't resolve the issue.
Is what I'm attempting even possible?
Thanks
-marc
I resolved it, not the best way, but it works. I decided to make the library targeted specifically for .NET Core 3.0. So, I changed the targetframework in the project file. That change automatically resolved my other issue.
Import the Microsoft.AspNetCore package, and use WebHost.CreateDefaultBuilder() instead. According to the code it is built from, both CreateDefaultBuilder() and ConfigureWebHostDefaults() call the same internal method: ConfigureWebDefaults().
The only downside of this is that the returned host will be an IWebHost instead of an IHost.

Using JUnit in Jython - NameError for assertTrue

Environment Details
Mac OS X 10.9
Oracle JDK 1.7.0_55 64-bit
jython-standalone-2.5.3.jar
junit-4.11
What I have done so far
I have added the junit jar to /Library/Java/Extensions.
I invoked Jython as follows java -jar jython-standalone-2.5.3.jar
In the Jython interpreter, I imported the following import org.junit.Assert, and this import was successful.
Problem
When I tried to use assertTrue, I got a NameError in the interpreter. Why is this so?
I understand that assertTrue is a static method. Not sure what implication this has when I try to use it in Jython.
Additional Context
I am using XMLUnit in Jython. Was able to successfully import the Diff class from org.custommonkey.xmlunit in Jython. Also able to use the methods in this class, and call them on a Diff object. The result of this method call is what I am trying to pass to assertTrue, when it throws the error.
from org.custommonkey.xmlunit import Diff
import org.junit.Assert
xml1 = ...some XML string...
xml2 = ...some XML string...
myDiff = Diff(xml1, xml2)
assertTrue(myDiff.similar())
Hope this additional information is useful in identifying a solution to this problem.
Latest Status
I narrowed it down to setting this property python.security.respectJavaAccessibility = false, since the Assert() constructor is protected.
Still trying to get it to work. Any help is greatly appreciated.
Figured it out.
In addition to junit.jar file, the hamcrest-core.jar file also needed to be copied to /Library/Java/Extensions.
Then I got rid of the jython.jar file, and instead installed it using the jython installer.
After the installation was completed, I updated the registry file in the installation folder, specifically setting this property python.security.respectJavaAccessibility = false.
Now I am able to see the assertTrue method, and no longer getting a NameError.

Dart confusing TYPE error

I am building a web application using dart with web_ui.
Everything was working fine until i added the web_ui pub, and now, when I am trying to run a build.dart file I get an error:
Uncaught Error: type 'AttributeName' is not a subtype of type 'String' of 'name'.
What does this mean?
From what I understand, this means there is somewhere an instance named 'name' of class 'AttributeName' that is extending 'String' class.
I searched my entire project and there is nowhere a class named 'AttributeName', nowhere an instance of 'name'.
I have the latest Dart editor and SDK:
Dart Editor version 0.4.7_r21658
Dart SDK version 0.4.7.5_r21658
EDIT:
this is my build.dart file:
import 'package:web_ui/component_build.dart';
import 'dart:io';
void main() {
build(new Options().arguments, ['web/menyplattan.html']);
}
Also, i updated all the pubs
This message looks like web_ui is failing a type check.
The similar SO question MarioP links to has a stacktrace showing this message coming from within the web ui library itself.
Do you have an xmlns attribute in your html?
Have a look at this web-ui issue.
AttributeName is defined within the html5lib library. Perhaps web-ui is expecting a newer version of this library but getting an older one. Make sure you've done a pub install. You can also try deleting your packages folder and doing a fresh pub install.
This could be caused by out-of-date packages, but it could also be a bug in web-ui. See if you can get a stacktrace and file a bug report, or post it on the web-ui mailing list.

Json does not exist in the namespace System

In this tutorial: http://www.asp.net/web-api/videos/getting-started/custom-validation Jon uses
dynamic error = new JsonObject();
with
using System.Json;
I guess it's the JsonObject here: http://msdn.microsoft.com/en-us/library/system.json.jsonobject(v=vs.110).aspx located in:
Namespace: System.Json
Assembly: System.Runtime.Serialization (in System.Runtime.Serialization.dll)
I've added System.Runtime.Serialization a reference but still cannot find System.Json.
Am I reading the Microsoft docs wrong? (I'm using .NET 4.5)
Try this:
PM> Install-Package System.Json -Version 4.0.20126.16343
Per: http://nuget.org/packages/System.Json
It worked!
If you have questions on how to add enter nuget code, please follow the link below:
http://docs.nuget.org/docs/start-here/using-the-package-manager-console
http://www.webcosmoforums.com/asp/32551-type-namespace-name-json-does-not-exist-namespace-system-runtime-serialization.html
Most likely you are missing a reference to System.ServiceModel.Web
Make sure your application is targeting the .Net 4.5 framework in the project properties.
The System.Json objects are only available in 4.5
Edit:
Use Nuget to install system.json : 'Install-Package System.Json'
How to parse JSON without JSON.NET library?
The Json object works only from Controller class and not outside. Even if we refer System.Web.MVC outside controller, we have access only to JsonResult and not to Json as Json object is protected object of JsonResult. Please refer the below documentation which explains that,
http://msdn.microsoft.com/en-us/library/dd504936(v=vs.118).aspx
If you want to use other .Net json serializer, you can use the following:
go to manage nuget package.
search json.net.
click install.
for more details, follow - http://netfx.codeplex.com/
Using System.json will not work for .Net 4 framework. The library is deprecated.
To check it try:
Go Add reference... to project.
On .Net Tab, Search System.json, you will not find any.
That means, it is deprecated.

Tell me the namespaces and references to be added to use CopyToDataTable method in linq for returning dataset

I cant see the System.data.datatableextensions in the reference list and hence not getting intellisence for CopyToDataTable method to return dataset from linq through aweb service.
Namespace: System.Data
Assembly: System.Data.DataSetExtensions (in System.Data.DataSetExtensions.dll)
http://msdn.microsoft.com/en-us/library/bb396189.aspx
--Jocke
If you go to the documentation of the CopyToDataTable method you will see at the very top the name of the assembly you need to reference. It is System.Data.DataExtensions.dll . If you don't have the documentation installed on your machine, you can find it simply by googling for CopyToDataTable. It is the first answer returned