Metro Modern UI " Failed to create component" C# Visual Studio 2019 - c#

I was trying out the Metro UI to create a C# application so I was testing out the framework tools in a new project. I've followed the instructions from https://n-a-r-w-i-n.github.io/MetroSet-UI/#how-to-use, as well as watching youtube videos where they install it via the Package Manager Console. All result in the same error I have been getting when I try to add an item to the form. Encountered Error
After running the design view goes completely blank and I cannot edit or do anything in that regard. Here is the code used for Form1.
using MetroFramework.Forms;
using MetroFramework;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace Test_App
{
public partial class Form1 : MetroForm
{
public Form1()
{
InitializeComponent();
}
}
}
I have notices I also have this warning.
Severity: Warning
Code: NU1701
Description: Package 'MetroModernUI 1.4.0' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8' instead of the project target framework '.NETCoreApp,Version=v3.1'. This package may not be fully compatible with your project.
Project: Test App.csproj
Line: 1
Please assist me to get a hang of this! Thank you for your time in advanced! :)

Related

Cant open the designer on a new project after a new install [duplicate]

This question already has an answer here:
Visual studio does not open the graphical editor for Winforms anymore
(1 answer)
Closed 3 years ago.
I installed Visual Studio 2019 Community completly new today and wanted to make a simple form. To do so I created a new "Windows Forms App (.NET Core)" in C#.
The problem is that I cant open the Designer. If I try to it always takes me to the code editor which just shows me the code editor with the following code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Tic
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
}
I have already tried uninstalling installing and making a few new projects. Always the same problem. I didnt alter any code.
Most recent update on the same was listed in the designer release note. Try installing the windowsformdesigner setup, and can be found here

How can i use an SQLiteAsyncConnection for Android using Xamarin?

I am trying to implement SQLite in a Xamarin solution using Visual Studio. However, i can not find the proper way to implement an SQLiteAsyncConnection.
I am following along a tutorial, which just passes a string to the constructor of the SQLiteAsyncConnection, however this is (no longer?) accepted. I googled to find a newer solution and almost everywhere found the solution to add a platform to the constructor, however that results in an error for me.
I think i might not have added the correct NUGet packages to the project(s). I have added the sqlite-net-pcl package to both the shared project and the android project.
I have also updated all NUGet packages today, rebuilt the solution and even deleted the /bin and /obj folder and it still is not working.
using System.IO;
using SQLite.Net;
using SQLite.Net.Async;
using Xamarin.Forms;
using SQLiteTest.Droid;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
[assembly: Dependency(typeof(SQLiteDB))]
namespace SQLiteTest
{
public class SQLiteDB : ISQLiteDB
{
public SQLiteAsyncConnection GetAsyncConnection()
{
const string fileName = "test.db3";
var documentsPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
var path = Path.Combine(documentsPath, fileName);
var platform = new SQLite.Net.Platform.XamarinAndroid.SQLitePlatformAndroid();
var cwLock = new SQLiteConnectionWithLock(platform, new SQLiteConnectionString(path, true));
var connection = new SQLiteAsyncConnection(() => cwLock);
return connection;
}
}
}
The error i get is:
Error CS0234 The type or namespace name 'Platform' does not exist in the namespace 'SQLite.Net' (are you missing an assembly reference?) SQLiteTest.Android D:\Mobile Apps\Mosh\SQLiteTest\SQLiteTest\SQLiteTest.Android\SQLiteDB.cs
Well, I am pretty sure you have not added the SQLite.Net.Platform.XamarinAndroid.dll package to your native Android project which is causing this issue when you use this dependency service.
If you are using SQLite-net and or SQLite.Net-PCL look for the Xamarin.Android platform dll int he path below:
packages\SQLite.Net-PCL.3.1.1\lib\MonoAndroid\`SQLite.Net.Platform.XamarinAndroid.dll`

Where are the `HttpContext.IsWebSocketRequest` property and the `HttpContext.AcceptWebSocketRequest` method?

I'm trying to get a simple "Hello World" type WebSocket server running on my Mac using Visual studio for Mac OS X.
Where are the HttpContext.IsWebSocketRequest property and the
HttpContext.AcceptWebSocketRequest method? The documentation appears to say they are in HttpContext inside the System.Web dll but I've referenced that (as well as System.Net) and Visual studio can't find them.
Is there something I'm missing or have forgotten?
This is the code I've that's giving me problems.
using System;
using System.Web;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Net.WebSockets;
using System.Collections.Generic;
public void ProcessRequest(HttpContext context)
{
if (context.IsWebSocketRequest)
context.AcceptWebSocketRequest(HandleWebSocket);
else
context.Response.StatusCode = 400;
}
The sample I'm following is: https://github.com/paulbatum/WebSocket-Samples/blob/master/AspNetWebSocketEcho/EchoHandler.ashx.cs
As far as I remember is not supported yet: http://go-mono.com/status/status.aspx?reference=4.5&profile=4.5&assembly=System
You can use one of the many third-party components available for Mono. I develop and maintain one of them https://github.com/vtortola/WebSocketListener

sqlite connection with c# XamlParseException

I have some difficult to make a connection with my existing sqlite db in c#. I want to make it for a WPF application.
This is my code :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Data.SQLite;
using Finisar.SQLite;
namespace Ebios_WPF
{
/// <summary>
/// Logique d'interaction pour MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
// We use these three SQLite objects:
Finisar.SQLite.SQLiteConnection sqlite_conn;
Finisar.SQLite.SQLiteCommand sqlite_cmd;
Finisar.SQLite.SQLiteDataReader sqlite_datareader;
// create a new database connection:
sqlite_conn = new Finisar.SQLite.SQLiteConnection("Data Source=existingDB.db; Version=3;");
// open the connection:
sqlite_conn.Open();
When I put an existing sqlite DB in argument I have an XamlParseException:
sqlite_conn = new Finisar.SQLite.SQLiteConnection("Data Source=existingDB.db; Version=3;");
but if i create a new database it works :
sqlite_conn = new Finisar.SQLite.SQLiteConnection("Data Source=NewDB.db; Version=3;New=True;");
Thank you for your help :)
Regards
I had this issue (and same error message) and found that sqlite.interop.dll was not automatically output/copied to where it should be in the main WPF project.
I have a class project ("Repository"), which uses System.Data.Sqlite.Core from Nuget. When I build that project, it outputs to it's bin\Debug\ directory, and it creates two sub-directories: "x64" and "x86" with sqlite.interop.dll in each. These directories are needed in the main (WPF) project, but are not moved there on build. So, to manage this, I've manually created a x64 and x86 folder in the Debug and Release bin directories of the main WPF and copy over sqlite.interop.dll. I've added this to my post build like so (first create the folders x64 and x86). "Repository" is the name of my project where the Sqlite Nuget package was installed.
copy "$(ProjectDir)Repository\bin\$(ConfigurationName)\x64\*.*" "$(ProjectDir)\bin\$(ConfigurationName)\x64\" /Y
copy "$(ProjectDir)Repository\bin\$(ConfigurationName)\x86\*.*" "$(ProjectDir)\bin\$(ConfigurationName)\x86\" /Y
I was able to resolve this in visual studio, but when I went to release the software and create an .msi, I forgot about the directories and had to also create them for my .msi.
I haven't tried it, but maybe you can just install Sqlite Nuget package into your WPF project.

How to write test case using Appium in C#?

I want to use Appium to make automated testing for my Android app. I downloaded the Appium for Windows and could run my app on device from within appium.exe. Now I want to write test cases in C# which make use of selendroid integrated in Appium. I googled a lot but couldn't find any example demonstrating the same. I found one project on github but it's giving a lot of compiler errors. Could anybody guide me about how to write test cases using Appium in C#? If you have any resources, please provide me the same. Thanks.
You can go with installing Visual Studio 2012 or visual express for web. Use NUnit framework to write the test cases and execute them as a class library project in that.
1) Create a class library project and create a new class e.g "Class1". Add the packages as provided in the links above. Try the below code
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using OpenQA.Selenium;
using OpenQA.Selenium.Remote;
using NUnit.Framework;
using OpenQA.Selenium.Interactions;
using System.Threading;
using OpenQA.Selenium.Appium;
using OpenQA.Selenium.Appium.MultiTouch;
using OpenQA.Selenium.Appium.Interfaces;
using System.Drawing;
namespace ClassLibrary2
{
[TestFixture]
public class Class1
{
public AppiumDriver driver;
public DesiredCapabilities capabilities;
public Class1()
{
Console.WriteLine("Connecting to Appium server");
capabilities = new DesiredCapabilities();
capabilities.SetCapability(CapabilityType.BrowserName, "Android");
capabilities.SetCapability(CapabilityType.Platform, "Windows");
capabilities.SetCapability(CapabilityType.Version ,"4.1.2");
capabilities.SetCapability("Device", "Android");
//Application path and configurations
driver = new AppiumDriver(new Uri("http://127.0.0.1:4723/wd/hub"), capabilities);
}
[Test]
public void login()
{
driver.FindElement(By.Name("Country")).Click();
//Your further code as per the application.
}
Then Build a solution for your project and run it in NUnit.

Categories