KeysConverter ConvertFrom ERROR when upgrade from dotnet 6 to dotnet 7 Preview 6 (Windows Forms) - winforms

i have windows forms project with following code:
string keysVal = "G"
Keys myKeys;
KeysConverter? keyConvert = new KeysConverter();
myKeys = (Keys)keyConvert.ConvertFrom(keysVal);
this code run on dotnet 6, but failed on dotnet 7
error:
StackTrace = " at System.ThrowHelper.ThrowKeyNotFoundException[T](T key)\r\n at System.Collections.Generic.Dictionary`2.get_Item(TKey key)\r\n at System.Windows.Forms.KeysConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)\r\n ...
Message = "The given key 'G' was not present in the dictionary."
any solutions?
or just bugs from dotnet 7?

Related

ABP/Swashbuckle - Generating swagger docs using Swashbuckle CLI

Using ABP Framework (3.3) and ASP.NET Core (3.1).
I'm attempting to generate swagger.json using Swashbuckle.AspNetCore.Cli (https://github.com/domaindrivendev/Swashbuckle.AspNetCore#retrieve-swagger-directly-from-a-startup-assembly) after compiling the application, pointing to the compiled dll using the following command:
dotnet swagger tofile --output "C:\temp\swagger" .\bin\Release\netcoreapp3.1\MyBin.dll v1
It gives me the below exception:
Unhandled exception. System.ArgumentNullException: Value cannot be null. (Parameter 'provider')
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
at Microsoft.Extensions.DependencyInjection.ServiceCollectionCommonExtensions.GetRequiredService[T](IServiceCollection services)
at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
at System.Lazy`1.CreateValue()
at System.Lazy`1.get_Value()
at Volo.Abp.AspNetCore.Mvc.AbpDataAnnotationAutoLocalizationMetadataDetailsProvider.CreateDisplayMetadata(DisplayMetadataProviderContext context)
at Microsoft.AspNetCore.Mvc.ModelBinding.Metadata.DefaultCompositeMetadataDetailsProvider.CreateDisplayMetadata(DisplayMetadataProviderContext context)
at Microsoft.AspNetCore.Mvc.ModelBinding.Metadata.DefaultModelMetadata.get_DisplayMetadata()
at Microsoft.AspNetCore.Mvc.ModelBinding.Metadata.DefaultModelMetadata.get_Order()
at Microsoft.AspNetCore.Mvc.ModelBinding.Metadata.DefaultModelMetadata.<>c.<get_Properties>b__78_0(ModelMetadata p)
at System.Linq.EnumerableSorter`2.ComputeKeys(TElement[] elements, Int32 count)
at System.Linq.EnumerableSorter`1.ComputeMap(TElement[] elements, Int32 count)
at System.Linq.EnumerableSorter`1.Sort(TElement[] elements, Int32 count)
at System.Linq.OrderedEnumerable`1.ToList()
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at Microsoft.AspNetCore.Mvc.ModelBinding.ModelPropertyCollection..ctor(IEnumerable`1 properties)
at Microsoft.AspNetCore.Mvc.ModelBinding.Metadata.DefaultModelMetadata.get_Properties()
at Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadataProviderExtensions.GetMetadataForProperty(IModelMetadataProvider provider, Type containerType, String propertyName)
at Microsoft.AspNetCore.Mvc.ApplicationModels.DefaultApplicationModelProvider.CreatePropertyModel(PropertyInfo propertyInfo)
at Microsoft.AspNetCore.Mvc.ApplicationModels.DefaultApplicationModelProvider.OnProvidersExecuting(ApplicationModelProviderContext context)
at Microsoft.AspNetCore.Mvc.ApplicationModels.ApplicationModelFactory.CreateApplicationModel(IEnumerable`1 controllerTypes)
at Microsoft.AspNetCore.Mvc.ApplicationModels.ControllerActionDescriptorProvider.GetDescriptors()
at Microsoft.AspNetCore.Mvc.ApplicationModels.ControllerActionDescriptorProvider.OnProvidersExecuting(ActionDescriptorProviderContext context)
at Microsoft.AspNetCore.Mvc.Infrastructure.DefaultActionDescriptorCollectionProvider.UpdateCollection()
at Microsoft.AspNetCore.Mvc.Infrastructure.DefaultActionDescriptorCollectionProvider.Initialize()
at Microsoft.AspNetCore.Mvc.Infrastructure.DefaultActionDescriptorCollectionProvider.get_ActionDescriptors()
at Microsoft.AspNetCore.Mvc.ApiExplorer.ApiDescriptionGroupCollectionProvider.get_ApiDescriptionGroups()
at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.GetSwagger(String documentName, String host, String basePath)
at Swashbuckle.AspNetCore.Cli.Program.<>c.<Main>b__0_3(IDictionary`2 namedArgs) in C:\projects\ahoy\src\Swashbuckle.AspNetCore.Cli\Program.cs:line 72
at Swashbuckle.AspNetCore.Cli.CommandRunner.Run(IEnumerable`1 args) in C:\projects\ahoy\src\Swashbuckle.AspNetCore.Cli\CommandRunner.cs:line 68
at Swashbuckle.AspNetCore.Cli.CommandRunner.Run(IEnumerable`1 args) in C:\projects\ahoy\src\Swashbuckle.AspNetCore.Cli\CommandRunner.cs:line 68
at Swashbuckle.AspNetCore.Cli.Program.Main(String[] args) in C:\projects\ahoy\src\Swashbuckle.AspNetCore.Cli\Program.cs:line 111
I've tried also creating a public class as per the Swashbuckle docs, as we are using Autofac:
public class SwaggerHostFactory
{
public static IHost CreateHost()
{
return Program.CreateHostBuilder(new string[0]).Build(); //Calls the same builder that's used to run the app
}
}
The intent is to allow running this in our pipelines to auto-generate ApiClient libraries.
I'm at a bit of a loss as to how to resolve this. The swagger.json is generated at runtime perfectly fine?
Any help appreciated!
One way to avoid this is to make sure your program continues without these app settings
var connectionString = config["MyConnectionString"];
if (connectionString != null)
{
services.AddDbContext<AppDbContext>(options =>
options.UseSqlServer(connectionString));
}
You can get the Swagger.json in a simple way without Swagger CLI.
Run your web with the dotnet command:
dotnet MyCompanyName.MyProjectName.Web.dll
Then download the Swagger.json with the following Powershell command:
Invoke-WebRequest -Uri https://localhost:5001/swagger/v1/swagger.json -OutFile c:\temp\swagger.json

How to get adf-richclient-automation-11.jar compatible with the latest selenium-java 3.x

I'm develping Selenium tests for Oracle ADF application.
I'm using for that:
JDeveloper fmw_12.2.1.3.0_bpmqs installation
Very usefull library SelniumTools
And I faced with problem:
The SelniumTools based on adf-richclient-automation-11.jar which is distributed with JDeveloper (use can find it in *Oracle_Home\oracle_common\modules\oracle.adf.view* folder) and described in docs as Oracle Customized Selenium.
And everything works fine with selenium-java library up to 2.53.1 version.
But when I upgrade selenium-java library to 3.3.1 version my test project fall with exception:
org.openqa.selenium.WebDriverException: java.lang.NoSuchMethodError: org.openqa.selenium.support.ui.**WebDriverWait.until(Lcom/google/common/base/Function;)Ljava/lang/Object;** Build info: version: 'unknown', revision: '5234b32', time: '2017-03-10 09:00:17 -0800' System info: host: 'EE-LATITUDE-749', ip: '10.10.207.64', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_172' Driver info: driver.version: unknown
com.redheap.selenium.junit.PageProvider.createPage(PageProvider.java:49)
com.redheap.selenium.junit.PageProvider.goHome(PageProvider.java:36)
ru.russvet.selenium.tests.P6_ProcessPageTest.(P6_ProcessPageTest.java:38)
java.lang.reflect.Constructor.newInstance(Constructor.java:423)
Caused by: java.lang.NoSuchMethodError: org.openqa.selenium.support.ui.WebDriverWait.until(Lcom/google/common/base/Function;)Ljava/lang/Object;
oracle.adf.view.rich.automation.selenium.RichWebDrivers.waitForServer(RichWebDrivers.java:112)
oracle.adf.view.rich.automation.selenium.RichWebDrivers.waitForRichPageToLoad(RichWebDrivers.java:175)
oracle.adf.view.rich.automation.selenium.RichWebDrivers.waitForRichPageToLoad(RichWebDrivers.java:158)
com.redheap.selenium.page.Page.(Page.java:53)
com.redheap.selenium.page.Page.(Page.java:45)
ru.russvet.selenium.pages.BPMWorkspaceLoginPage.(BPMWorkspaceLoginPage.java:19)
com.redheap.selenium.junit.PageProvider.createPage(PageProvider.java:47)
Investigations follow to the reason:
1) in selenium-java library starting from 3.3.1 interface for until function has been changed and accept Function, Predicate или Supplier classes from Java 8 library instead of Guava library https://github.com/SeleniumHQ/selenium/commit/b2aa9fd534f7afbcba319231bb4bce85f825ef09 :
-import com.google.common.base.Function;
-import com.google.common.base.Predicate;
-import com.google.common.base.Supplier;
+import java.util.function.Function;
+import java.util.function.Predicate;
+import java.util.function.Supplier;
2) what could be probably worked around with recent guava release (21+ version), where the Google versions of both Function and Predicate extend the Java 8 equivalents
So, it is look like that adf-richclient-automation-11.jar is built with selenium-java library 2.x, and that causes the exception during running the tests.
We raised it via Oracle support, but there is no information from them about new version for this library yet.
So, my questions are:
1) what is possible way to rebuild the adf-richclient-automation-11.jar to make it compatible with the latest version of selenium-java as 3.x?
2) Has anybody found newer version of adf-richclient-automation-11.jar in maybe some specific distribution of JDeveloper?
I was once upon a time part of the small team within Oracle that built the automation library you are referring to.
The issue here is API compatibility and unless the ADF automation library is repackaged against WebDriver 3.x and redistributed by Oracle OTN, you have no options but to stick to using Selenium 2.x libraries. WebDriver 3.x is meant for Java 8, which would be one more reason Oracle would want to soon upgrade to 3.x. Have you raised your concerns via OTN forums or Oracle support?
Well, answer myself. The only way for now to make this works were decompiling adf-richclient-automation-11.jar, clean and repackage it against WebDriver 3.x.
The corresponding Eclipse project is here https://github.com/EgorBEremeev/adf-richclient-automation-selenium-3-rebuild
This project does not contains test classes as original lib. I didn't run any tests from the original lib because I have no idea of required test environment for that.
So, I tested the repackaged library directly in my main project.
How ever the complete steps to get sources, clean it, fix errors and repackage library you can find in readme.md in the git repository and as well below:
Full Steps to manualy rebuilt adf-richclient-automation-11.jar:
Environment
Install Eclipse
Install Decompiler pluging
Help -> Marketplace -> Enhanced Class Decompiler
Windows -> Preferences -> Java -> Decompiler -> Default Class Decompiler: CFR -> Applay and Close
Set User Libraries
Windows -> Preferences -> Java -> Build Path -> User Libraries
New->
Name -> selenium-java-3.3.1
Add External JARs... ->
path\to\selenium-java-3.3.1\
client-combined-3.3.1-nodeps.jar
lib\*.jar
->Finish
New->
Name -> adf-richclient-automation-11.jar
Add External JARs... ->
path\to\Oracle_Home\oracle_common\modules\oracle.adf.view\
adf-richclient-automation-11.jar
->Finish
-> Applay and Close
Steps
Create Java Project
Eclipse -> New -> Java Project
Name -> project_name
JDK -> 1.8
Build Path -> Libraries -> Add Library -> User Library -> Next
User Libraries ...
selenium-java-3.3.1
adf-richclient-automation-11.jar
Decompile adf-richclient-automation-11.jar
Project Explorer -> adf-richclient-automation-11.jar -> Context Menu -> Export Sources
path\to\project_name\src\
adf-richclient-automation-11-src.zip
Project Explorer -> Refresh
src -> adf-richclient-automation-11-src.zip
Extract decompiled sources into path\to\project_name\src\
Check the src
Project Explorer -> Refresh
src -> adf-richclient-automation-11-src.zip
* oracle.adf.view.rich.automation.selenium
* oracle.adf.view.rich.automation.test
oracle.adf.view.rich.automation.test.browserfactory
* oracle.adf.view.rich.automation.test.component
* oracle.adf.view.rich.automation.test.selenium
org.openqa.selenium
org.openqa.selenium.firefox
5.1 Delete classes used for and with Selenium RC:
path/to/project_name/src/
oracle/adf/view/rich/automation/selenium/RichSelenium.java -> Delete
5.2 Delete packages oracle.adf.view.rich.automation.test.* -> Delete
oracle.adf.view.rich.automation.test
oracle.adf.view.rich.automation.test.browserfactory
oracle.adf.view.rich.automation.test.component
oracle.adf.view.rich.automation.test.selenium
Fix errors:
path/to/project_name/src/oracle/adf/view/rich/automation/selenium/RichWebDrivers.java
[] 241 Type mismatch: cannot convert from element type Object to String ->
fix 239 -> List<String> logs = (List) jsExecutor.executeScript(_GET_AND_CLEAR_LOG_MESSAGES_JS,
=
List<String> logs = (List) jsExecutor.executeScript(_GET_AND_CLEAR_LOG_MESSAGES_JS,
new Object[]{logLevel.toString().toUpperCase()});
for (String s : logs) {
sbf.append(s).append(_NEW_LINE);
}
[] 321 Type mismatch: cannot convert from element type Object to String ->
fix 320 -> Set<String> handles = webDriver.getWindowHandles();
=
public String apply(WebDriver webDriver) {
Set<String> handles = webDriver.getWindowHandles();
for (String handle : handles) {
if (openWindowHandles.contains(handle))
continue;
return handle;
}
return null;
}
Build and Export into jar
remove -> path\to\project_name\src\adf-richclient-automation-11-src.zip
Project Explorer -> Export -> Java -> JAR file -> Next
select src folder only
check Export generated classes and resources
uncheck .classpath, .project
-> Finish -> Ok in warning dialog
Optional fix error in classes from oracle.adf.view.rich.automation.test.* packages.
path/to/project_name/src/oracle/adf/view/rich/automation/test/selenium/WebDriverManager.java
[] 87 Type mismatch: cannot convert from element type Object to String ->
fix 85 Set<String> windowHandles = webDriver.getWindowHandles();
=
try {
Set<String> windowHandles = webDriver.getWindowHandles();
_LOG.fine("try to close all windows... ");
for (String handle : windowHandles) {
path/to/project_name/src/oracle/adf/view/rich/automation/test/selenium/RichWebDriverTest.java
[] 953 Syntax error on token "finally", delete this token ->
fix -> delete 956,952,949, 941
=
protected void refresh() {
_LOG.fine("Executing refresh()");
this.getWebDriver().navigate().refresh();
try {
Alert alert = this.getWebDriver().switchTo().alert();
if (alert != null) {
alert.accept();
};
}
catch (WebDriverException alert) {}
finally {
this.waitForPage();
}
}
[] 1026 Unreachable catch block for Exception. It is already handled by the catch block for Throwable ->
fix -> replace whole method by variant of Jad Decompiler->
-> Windows -> Preferences -> Java -> Decompiler -> Default Class Decompiler: Jad -> Applay and Close
-> fix 1020, 1028 Duplicate local variable cachingEnabled ->
fix-> delete
-> 1019 String msg;
-> 1018 boolean cachingEnabled;
=
protected void onShutdownBrowser() {
_LOG.finest("Shutting down browser");
try {
_logSeleniumBrowserLogAndResetLoggerLevel();
} catch (Exception e) {
boolean cachingEnabled;
String msg;
_LOG.warning("The page did not generate any logs.");
} finally {
boolean cachingEnabled = isBrowserCachingEnabled();
try {
if (cachingEnabled) {
getWebDriverManager().releaseInstance();
} else {
getWebDriverManager().destroyInstance();
}
} catch (Throwable t) {
String msg = cachingEnabled
? "Failed to release the browser. Error message: %s"
: "Failed to shutdown the browser. Error message: %s";
_LOG.severe(String.format(msg, new Object[]{t.getMessage()}));
}
}
}
[] 1047 Type mismatch: cannot convert from element type Object to WebElement ->
fix 1046 List<WebElement> allOptions = element.findElements(By.xpath((String) builder.toString()));
=
List<WebElement> allOptions = element.findElements(By.xpath((String) builder.toString()));
for (WebElement option : allOptions) {
path/to/project_name/src/oracle/adf/view/rich/automation/test/UrlFactories.java
[] 34 Type mismatch: cannot convert from UrlFactory to UrlFactories.UrlFactoryImpl ->
fix Add cast to 'UrlFactoryImpl'
=
factory = (UrlFactoryImpl) urlFactoryIterator.next();
[] 52 Type mismatch: cannot convert from UrlFactory to UrlFactories.UrlFactoryImpl
fix Add cast to 'UrlFactoryImpl'
=
UrlFactoryImpl urlFactoryImpl = (UrlFactoryImpl) (_INSTANCE = factory != null ? factory : new UrlFactoryImpl());

How to Dapper & AseClient

Unable to connect to Sybase, not getting error.
I have referenced Sybase.AdoNet4.AseClient.dll from C:\Sybase\DataAccess\ADONET\dll to my MVC 5 project, running in .NET 4.5
Web.Config Connections string
<add name="MyASEServer" connectionString="Data Source=127.0.0.20:12000;Initial Catalog=MyDB;User Id=USer1;Password=Password1;"
providerName="Sybase.Data.AseClient"/>
My code
string constr = ConfigurationManager.ConnectionStrings["MyASEServer"].ConnectionString;
IDbConnection aseDB = new AseConnection(constr );
var myCustomer = aseDB.Query<Customer>("select * fromdbo.customer");
When the debugger reaches aseDB.Query...., it never return and not receiving any error.
What am I missing.
In this case, Application Insights is on in visual studio and all the exceptions are captured in it. So the application screen is not showing the exception.

Unable to run application outside of Visual Studio

Our .Net 4.0 app that runs normally while hosted by VS always crashes while loading (less than 1 second after executing) while not debugging (both debug and release binaries).
The app contains 5 libraries (all of it with .Net 4.0) + NHibernate dependencies.
It does not even fire the UnhandledException event, it just crashes right away with a OutOfMemoryException (I could only see that with the Windows Event Viewer).
Event Viewer tells me that kernelbase.dll had a OutOfMemoryException, and
Fuslogvw.exe tells me that System.Core fails to load:
*** Input Assembly Binder Log (6/27/2016 # 15:41:54) ***
The operation failed.
Result of the Association: hr = 0x8007000e. Insufficient storage space to complete the operation.
Assembly Manager loaded from: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
Running under executable C:\Users\User\Source\Manager\MySoftware\MySoftware.WPF.App\bin\Release\MySoftware.WPF.App.exe
---Follows a detailed log of errors.
=== Pre-Association state information ===
LOG: DisplayName = System.Core, Version = 4.0.0.0, Culture = neutral, PublicKeyToken = b77a5c561934e089
(Fully-specified)
LOG: Appbase = file:///C:/Users/User/Source/Manager/MySoftware/MySoftware.WPF.App/bin/Release/
LOG: initial PrivatePath = NULL
Logging: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = MySoftware.WPF.App.exe
Calling assembly: MySoftware.WPF. App, Version 1.0.0.0, Culture = neutral, PublicKeyToken = null.
===
LOG: this Association starts at the default load context.
LOG: using application configuration file: C:\Users\User\Source\Manager\MySoftware\MySoftware.WPF.App\bin\Release\MySoftware.WPF.App.exe.Config
LOG: using host configuration file:
LOG: using machine configuration file C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: post policy reference: System.Core, Version = 4.0.0.0, Culture = neutral, PublicKeyToken = b77a5c561934e089
LOG: assembly located by searching on GAC.
ERR: unrecoverable error during pre download verification (hr = 0x8007000e).
I have 4GB of RAM with 60% occupied, so maybe that's not the problem. Can you give me a hint where to look?

Silverlight unit testing. Error while running tests

I'm using VS2010. Silverlight 4, NUnit 2.5.5, and TypeMock
TypemockIsolatorSetup6.0.3.619.msi
In the test project MVVM is implemented, PeopleViewModel is a ViewModel which I want to test.
Please advise if you use other products for unit testing of MVVM Silverlight. Or please help to win this TypeMock. TIA
This is the code of the test:
[Test]
[SilverlightUnitTest]
public void SomeTestAgainstSilverlight()
{
PeopleViewModel o = new PeopleViewModel();
var res = o.People;
Assert.AreEqual(15, res.Count());
}
While running the test in ReSharper i get the following error:
TestA.SomeTestAgainstSilverlight : Failed******************************************
*Loading Silverlight Isolation Aspects...*
******************************************
TEST RESULTS:
---------------------------------------------
System.MissingMethodException : Method not found: 'hv TypeMock.ArrangeActAssert.Isolate.a(System.Delegate)'.
at a4.a(ref Delegate A_0)
at a4.a(Boolean A_0)
at il.b()
at CThru.Silverlight.SilverlightUnitTestAttribute.Init()
at CThru.Silverlight.SilverlightUnitTestAttribute.Execute()
at TypeMock.MockManager.a(String A_0, String A_1, Object A_2, Object A_3, Boolean A_4, Object[] A_5)
at TypeMock.InternalMockManager.getReturn(Object that, String typeName, String methodName, Object methodParameters, Boolean isInjected)
at Tests.TestA.SomeTestAgainstSilverlight() in TestA.cs: line 21
While running test in NUnit i get:
Tests.TestA.SomeTestAgainstSilverlight:
System.DllNotFoundException : Unable to load DLL 'agcore': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
at MS.Internal.XcpImports.Application_GetCurrentNative(IntPtr context, IntPtr& obj)
at MS.Internal.XcpImports.Application_GetCurrent(IntPtr& pApp)
at System.Windows.Application.get_Current()
at ViewModelExample.ViewModel.ViewModelBase.get_IsDesignTime() in C:\Documents and Settings\USER\Desktop\ViewModelExample\ViewModelExample\ViewModel\ViewModelBase.cs:line 20
at ViewModelExample.ViewModel.PeopleViewModel..ctor(IServiceAgent serviceAgent) in C:\Documents and Settings\USER\Desktop\ViewModelExample\ViewModelExample\ViewModel\PeopleViewModel.cs:line 28
at ViewModelExample.ViewModel.PeopleViewModel..ctor() in C:\Documents and Settings\USER\Desktop\ViewModelExample\ViewModelExample\ViewModel\PeopleViewModel.cs:line 24
at Tests.TestA.SomeTestAgainstSilverlight() in C:\Documents and Settings\USER\Desktop\ViewModelExample\Tests\TestA.cs:line 22
UPDATE: I'm not following the question. I've switched to other tools.
This message looks like a mismatched files issue. Try creating a new test project from scratch.
Start by adding references to Typemock.dll and Typemock.ArrangeActAssert.dll. From the CThru directory add both CThru.dll and CThru.Silverlight.dll.
Add a reference to System.Windows (located at C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\Silverlight\v4.0\System.Windows.dll).
Try creating a new test method, and decorate it with SilverlightUnitTest attribute:
using NUnit.Framework;
using CThru.Silverlight;
[TestFixture]
public class SilverlightTest
{
[Test, SilverlightUnitTest]
public void EmptyTest()
{
}
}
Run this empty test. If you're still having the problem you described, please contact support at typemock.com for further assistance.

Resources