I'm trying to establish connection to Azure DataExplorer cluster using C# ..
I referenced the C# in https://learn.microsoft.com/en-us/azure/kusto/api/netfx/about-kusto-data
and installed nuget package kusto.data in visual studio and copied the code and did dotnet run in cmd prompt, but it didn't work.
Below is my code-
using Microsoft.Azure.Management.Kusto;
using System;
namespace LensDashboradOptimization
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
//var clusterUrl = "https://masvaas.kusto.windows.net";
//var kcsb = new Kusto.Data.KustoConnectionStringBuilder(clusterUrl);
//Console.WriteLine(kcsb);
// Read the first row from reader -- it's 0'th column is the count of records in MyTable
// Don't forget to dispose of reader when done.
var client = Kusto.Data.Net.Client.KustoClientFactory.CreateCslQueryProvider("https://masvaas.windows.net/Samples;Fed=true");
var reader = client.ExecuteQuery("MyTable | count");
Console.WriteLine(reader);
}
}
}
I tried both fed=true and WithAadUserPromptAuthentication(); both didn't work. Am I missing something?
Hello and welcome to Stack Overflow!
I tried and faced a similar error when I was checking this out. But the issue turned out to be with the version of .Net Framework that I was running. The Kusto.Data package requires .Net Framework 4.6.2 as a dependency. When I had that installed, I was able to install and import the package, and also subsequently connect to the intended Kusto cluster and read data. This is the snippet that worked for me:
using System;
using Kusto.Data;
namespace hello_world
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
var client = Kusto.Data.Net.Client.KustoClientFactory.CreateCslQueryProvider("https://help.kusto.windows.net/Samples;Fed=true");
var reader = client.ExecuteQuery("StormEvents | sort by StartTime desc | take 10");
}
}
}
Please double check on the dependencies and let me know if you still run into issues. Hope this helps!
using Kusto.Data;
using Kusto.Data.Common;
using Kusto.Data.Net.Client;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
Only these using statement do the job that you are trying to. For that all you need to install SDK from nuget gallery .
Also, only install Microsoft.Azure.Kusto.Data and Microsoft.Azure.Management.Kusto from above. That is sufficient.
Hope this help.
Few more things you can look on as: 1) Static IP 2)VS 2019 community edition with Azure dev packages installed
WithAadUserPromptAuthentication, this method is not supported now as kusto database first need authentication for the user. and the console application is not able to open a prompt window. I recommend to use a web application.
Related
i can't use Syetem.Data.SqlClient.
this is my code
using System;
using System.Data.SqlClient; // <== error
namespace ConsoleApplication
{
public class Program
{
public static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}
i make this project from console, and input 'dotnet new' and restore.
what shold i do?
Have you added "System.Data.dll" to your project reference?
Add reference for SQL server data from project references. If there is not such option then run the Setup of visual studio select option Modify and then select SQL data option and run the setup.
I've been searching for a few hours for a solution for my problems. But I've downloaded Cosmos (operating system) using visual studio 2015 community edition. At first I downloaded the userkit, then realized that I wanted the devkit (maybe). All the examples I see online are using this:
using Cosmos.Compiler.Builder;
But that isn't working for me. ( I did change the properties to use the 3.5 framework, i read that I must use that and now it's not finding Cosmos anywhere. Before when I was using framework 4.5 I could use cosmos, but only Cosmos.System and one other. Any ideas on what I'm doing wrong?
This is what I'm getting in Kernel.cs when I first start a cosmos project:
using System;
using System.Colletions.Generic;
using System.Text;
using Sys = Cosmos.System;
namespace CosmosKernel1
{
public class Kernel : Sys.Kernel
{
protected override void BeforeRun()
{
Console.WriteLine("Cosmos booted successfully. Type a line of text to get it echoed back.");
}
protected override void Run()
{
Console.Write("Input: ");
var input = Console.ReadLine();
Console.Write("Text type: ");
Console.WriteLine(input);
}
}
}
First make sure that you have a COSMOS PROJECT and not a typical c# console app or something.
Second, after confirming that, make sure you have cosmos.compiler and all the cosmos dlls in your references.
Tutorial: https://www.youtube.com/watch?v=oKW3BrclAUY
I have a C# program running under Visual Studio 15 .NET Framework 4.5.2. It uses AutoMapper 4.1.1. It's been running fine for years. (I inherited it from someone else.) Just lately, it started erroring out at the line "AutoMappings.AutoMappings.CreateMaps();" Here's the relevant code:
using System;
using System.Windows.Forms;
using IVGOffice.UserInterface;
using System.Net;
using System.Net.Security;
namespace IVGOffice
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
// Assign certification callback to allow for self-signed certs on the services
ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(IVG.Common.Certificate.ValidateRemoteCertificate);
AutoMappings.AutoMappings.CreateMaps(); // <----- Errors out here
It throws a System.TypeInitiializationException with inner error "Configuration system failed to initialize". It never actually enters into the AutoMappings class, so I don't think the problem is related to the class, but here's the beginning of it anyway:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using IVG.Common;
using IVG;
namespace IVGOffice.AutoMappings
{
public static class AutoMappings
{
private static bool mapsCreated = false;
private static Utilities2.Services services = new Utilities2.Services();
public static void CreateMaps()
{
// AutoMapper CreateMap should only be called once in an application domain. If we call this twice, check and just leave the second time
if (mapsCreated)
return;
// For every IAutomappedObject
System.Reflection.Assembly assm = System.Reflection.Assembly.GetCallingAssembly();
var interfaceTypes = assm.GetTypes();
var automappedTypes = interfaceTypes.Where(type => typeof(IAutomappedObject).IsAssignableFrom(type)
&& !type.IsAbstract
&& !type.IsInterface);
foreach (var type in automappedTypes)
...
My coworker tried running the same code on his laptop and it worked fine, so there must be something going on with my copy of Visual Studio or my computer settings. I've tried running different versions of the program, rebooting, restoring the program from backup, etc. to no avail.
Anybody have any ideas? Thanks.
I hit this today because I stupidly placed appSettings before the configSections in my app.config file.
The error possibly indicates that your config file contains illegal syntax/layout. I'd start your investigation there.
The problem was in the configuration, but not in app.config. I had added code to save and restore the window status, location, and size. These settings were saved into a new user.config file. The problem was that I had added this code to a new git repo. My boss had to approve the changes before merging them into the master repo. In the meantime, I had gone back to the master to start a new project. The master didn't have the new code, but the new user.config file was still there. For some reason, that seems to have confused the program. When my boss finally merged the new code and I updated my copy of the master, the problem went away. Thanks for your feedback.
I want to use SikuliIntegrator in C#.
I run VS as administrator, install SikuliIntegrator throught NuGet manager and want to test him on simple task.
Heres my code
using SikuliModule;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SikuliTrainingNet
{
class Program
{
static void Main(string[] args)
{
string MyPicture = #"c:\111\Sik\MyPicture.png";
SikuliAction.Click(MyPicture);
}
}
}
after running code (and have prepared MyPicture on screen), all i get is exception "###FAILURE" any idea why?
I dont wanna use Sikuli4Net, becose its look like it work on web aps and I need just few simple clicks on desktop aplication.
I try sikuli in Java, and there it works with no problem. But I need to make my program in C#.
I Used This Code For Sikuli4Net in C#,It Was Working For Me First You need add the References please see this link for Reference
http://interviews.ga/angularjs/sikulic/
static void Main(string[] args)
{
APILauncher launch = new APILauncher(true);
Pattern image1 = new Pattern(#"C:\Users\Ramesh\Desktop\Images\userName.png");
Pattern image2 = new Pattern(#"C:\Users\Ramesh\Desktop\Images\password.png");
Pattern image3 = new Pattern(#"C:\Users\Ramesh\Desktop\Images\Login.png");
launch.Start();
IWebDriver driver = new ChromeDriver();
driver.Manage().Window.Maximize();
driver.Url = "http://gmail.com";
Screen scr = new Screen();
scr.Type(image1, "abc#gmail.com", KeyModifier.NONE);
scr.Type(image2, "12345", KeyModifier.NONE);
scr.Click(image3, true);
Console.ReadLine();
}
I used this code and it was working fine. First you should open the webpage on which you want to click and then give a path of the image(it should be a part of the webpage)
here is my code:
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using SikuliModule;
using OpenQA.Selenium;
namespace WordPressAutomation.DifferentTests
{
[TestClass]
public class Sikuli
{
[TestMethod]
public void TestMethod1()
{
driver.Initialize();
driver.instance.Navigate().GoToUrl("https://www.google.co.in");
SikuliAction.Click("E:/img.png");
}
}
}
To use SikuliInyegrator, you need to check the execution results in these files:
C:\SikuliExceptionLog.txt
C:\SikuliOutputLog.txt
Also you need to:
Have installed JRE7 or superior
Have environment variable PATH with the location of the bin folder
See installed in your “control panel > program and features> visual C++ 2010 Redistributable Package” at x86 and x64 bits according to your java JRE runtime platform. If not, then download and install the Redistributable Package form Microsoft site.
All,
Please forgive my ignorance of C#/.NET, I am absolutely new to both (mostly Java, C/C++) and find myself tasked with creating some code that performs the same thing as the "wmic qfe" and "wmic os" commands available at the DOS prompt.
Can this be done? If so, any help is appreciated. I am trying to working my way through the System.Management.Instrumentation namespace since wmic is an acronym for Windows Management Instrumentation Command (according to Google), but have as yet to discover anything useful.
Thanks in advance,
Toddw
Instead of using the Management class, you can simply invoke the wmic.exe which is a WMI console as you can figure out from the exe name itself. Here is the code that I used to open notepad on a remote computer using WMIC invoked through C#.net. Try it out.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
namespace RemoteProcessDemo
{
class Program
{
static void Main(string[] args)
{
string strComputerName = "";
string strProcString = "";
try
{
strComputerName = args[0];
Process.Start("wmic", "/node:" + strComputerName + " process call create notepad.exe");
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
}
}
Regards,
Tushar
You will indeed need to use the System.Management namespace to perform WMI queries. There is lots info on using WMI from C#, Microsoft's is (archived) here
For your specific cases:
qfe - query the Win32_QuickFixEngineering class
os - query the Win32_OperatingSystem class