Console dialog missing during debug in Visual Studio 2017 - c#

I recently started working with Visual Studio 2017. Jumping from 2010.
I created a new, very basic, console application and I am trying to test. The code runs fine but I am not seeing a console dialog anywhere (I have breakpoints and also a Console.Read()). I checked 'behind' all the windows. See nothing in the task tray.
Any ideas? Any new settings that I am not aware of?
Here is all of the code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleTest2
{
class Program
{
static void Main(string[] args)
{
Console.Read();
}
}
}
Definitely a console application.
Project Info

Related

Why does Visual Studio not complain when I write Console.WriteLine?

I was recently watching tutorials on C# where they mentioned that specifying either using System and then using Console.WriteLine or writing System.Console.WriteLine if you don't specify using <namespace> was necessary for proper namespace resolution to happen when writing programs otherwise the compilation would fail.
But when I'm using Visual Studio 2022, Console.WriteLine seems to work without specifying any namespace at all.
Is this some optimisation that Visual Studio 2022 does? Why is this working?
On top of this, if I use System.Console.WriteLine, VS 2022 also greys out System and says "name can be simplified".
Try this
using System;
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
If you create c# project of asp.netframrwork. It will automatically generate the "using System" namespace.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace ConsoleApp2
{
internal class Program
{
static void Main(string[] args)
{
}
}
}
If your console project is .NET 6 and above. Please refer to Exploring Ideas to Build Code While Learning Using Top-Level Statements.
Hope it helps you.

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

Sikuli error in c# with Sikuli integrator package

When I run this code:
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using Sikuli4Net.sikuli_REST;
using Sikuli4Net.sikuli_UTIL;
using SikuliModule;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace Sikuli
{
class Program
{
static void Main(string[] args)
{
driver = new ChromeDriver();
driver.Manage().Window.Maximize();
driver.Navigate().GoToUrl("https://www.google.co.nz/");
Thread.Sleep(2000);
String image = #"C:\Users\safa\Desktop\gmail.jpg";
SikuliAction.Click(image);
}
}
}
I got this exception:
System.ComponentModel.Win32Exception:
'The system cannot find the file specified'
I changed file location but again I got same error.
This the image that I want to click on:
Run the visual studio as administrator using below steps
Click on start(windows) button
Type Visual Studio
Mouse Right Click on Visual Studio
Click on Run as Administrator option
I think there is no mistakes in code. So try this once.
Increase the wait time to 5000ms
For this program you don't need Sikuli4Net, remove usings related to that

How do I add a reference to HTMLAgilityPack in Visual Studio Code

I'm using Visual Studio Code and .NET core on OSX.
HtmlAgilityPack.NetCore.1.5.0.1 has been installed to the project folder. All of my project files, HTMLAgilityPack.NetCore.1.5.0.1 and all of the dependencies are visible in the explorer pain. Yet I cannot create a reference to any HtmlAgilityPack assemblies.
The code is simple. It compiles and runs.
namespace ConsoleApplication
{
using System;
using System.Text.RegularExpressions;
using System.Linq;
public class Program
{
public static void Main(string[] args)
{
Console.WriteLine("Hello, world");
}
}
}
Is there a step beyond installing the nuget package that I need to perform to get this to work?
Unless I'm misunderstanding your question, this should be very straight forward. All you need to do is:
1: Add the nuget package into your project.json file like so, then run dotnet restore in the same directory as your project.json file to restore your newly added package.
...
},
"dependencies": {
"HtmlAgilityPack.NetCore": "1.5.0.1"
},
"frameworks": {
...
2: Add the following using statement to the top of your code.
using HtmlAgilityPack;
This works for me:
namespace ConsoleApplication
{
using System;
using HtmlAgilityPack;
public class Program
{
public static void Main(string[] args)
{
HtmlDocument doc = new HtmlDocument();
Console.WriteLine("Hello, world");
}
}
}
Note:
As you're using Visual Studio Code on OSX, you can reference a class and then press the shortcut CMD + . to bring up Visual Studio Code's tool window and automatically import your missing using statement.

Matlab dll included in C# project on client pc

I'm working on Matlab and C# projects, I've created a DLL file from the Matlab project and run it on the C# project.
My code works fine on my computer and on any Windows 7 x64 bit that I've tested.
The problem is with Windows 8, When I'm trying to run my app on Win 8 PC the app collapsed while calling to the main class that included in the DLL.
I tried to catch the error, but no error occurred, the app just crashed.
I've already installed MCR for the specific Matlab version, but it still doesn't work.
I believe that I'm missing some system configuration, can someone help to do some order what exactly should I do in order to run it?
UPDATE1:
The 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;
using System.IO;
using VisionCameraQA;
using MathWorks.MATLAB.NET.Arrays;
using MathWorks.MATLAB.NET.Utility;
namespace VisionCameraQATest
{
public partial class Form1 : Form
{
cls_Main main;
public Form1()
{
InitializeComponent();
try
{
main = new cls_Main();
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString())
}
}
}
}
The app crashes while getting to main = new cls_Main();, it is not reached to the catch at all.

Categories