c#

The locale en-EN is an invalid culture identifier

耗尽温柔 提交于 2021-02-20 18:58:38
问题 I recently shifted from a computer which had Windows 10 with VS 2017 to a computer which had Windows 8.1 with VS 2017. I was working with a piece of code which had a line like this. Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(locale); Here, locale value is en-EN . I got hit with a surprise when this threw a CultureNotFoundException exception with a message. en-EN is an invalid culture identifier. Surprising to me because, the same code with locale as en-EN works in

Create or replace node in an XML without root in C#

大兔子大兔子 提交于 2021-02-20 18:55:46
问题 I have an XML file like this: <Something>....</Something> <Another>....</Another> <Other>...</Other> This XML file does not have a root element (I know that this is a wrong XML format). I need to create or replace (if it already exists) a node in this XML, but I can't work with XDocument or XmlDocument because they need a root element to work, and I can't add a root element to this XML because I can't change more code in the Application (Windows forms application). What are my options to

Create or replace node in an XML without root in C#

好久不见. 提交于 2021-02-20 18:54:12
问题 I have an XML file like this: <Something>....</Something> <Another>....</Another> <Other>...</Other> This XML file does not have a root element (I know that this is a wrong XML format). I need to create or replace (if it already exists) a node in this XML, but I can't work with XDocument or XmlDocument because they need a root element to work, and I can't add a root element to this XML because I can't change more code in the Application (Windows forms application). What are my options to

Create or replace node in an XML without root in C#

一笑奈何 提交于 2021-02-20 18:54:03
问题 I have an XML file like this: <Something>....</Something> <Another>....</Another> <Other>...</Other> This XML file does not have a root element (I know that this is a wrong XML format). I need to create or replace (if it already exists) a node in this XML, but I can't work with XDocument or XmlDocument because they need a root element to work, and I can't add a root element to this XML because I can't change more code in the Application (Windows forms application). What are my options to

Printing landscape/portrait in rdlc without preview

女生的网名这么多〃 提交于 2021-02-20 18:50:22
问题 I am trying to print a local report in either landscape or portrait. private void Export(LocalReport report) { Warning[] warnings; m_streams = new List<Stream>(); var deviceInfo = new StringBuilder(); deviceInfo.AppendLine("<DeviceInfo>"); deviceInfo.AppendLine("<OutputFormat>EMF</OutputFormat>"); //"11.7in", "8.3in" deviceInfo.AppendLine("<PageWidth>11.7in</PageWidth>"); deviceInfo.AppendLine("<PageHeight>8.3in</PageHeight>"); deviceInfo.AppendLine("</DeviceInfo>"); report.Render("Image",

Printing landscape/portrait in rdlc without preview

跟風遠走 提交于 2021-02-20 18:48:07
问题 I am trying to print a local report in either landscape or portrait. private void Export(LocalReport report) { Warning[] warnings; m_streams = new List<Stream>(); var deviceInfo = new StringBuilder(); deviceInfo.AppendLine("<DeviceInfo>"); deviceInfo.AppendLine("<OutputFormat>EMF</OutputFormat>"); //"11.7in", "8.3in" deviceInfo.AppendLine("<PageWidth>11.7in</PageWidth>"); deviceInfo.AppendLine("<PageHeight>8.3in</PageHeight>"); deviceInfo.AppendLine("</DeviceInfo>"); report.Render("Image",

how can I change forecolor of a chart label?

柔情痞子 提交于 2021-02-20 18:45:09
问题 how can i change the fore color of the chart labels? here's a screenshot of the chart i tried using the chart1.series[0].FontForeColor = color.white; but the entire chart turns white. 回答1: Try this: this.chart1.BackColor = Color.AliceBlue; this.chart1.ChartAreas[0].AxisX.LineColor = Color.Red; this.chart1.ChartAreas[0].AxisX.MajorGrid.LineColor = Color.Red; this.chart1.ChartAreas[0].AxisX.LabelStyle.ForeColor = Color.Red; this.chart1.ChartAreas[0].AxisY.LineColor = Color.Red; this.chart1

how can I change forecolor of a chart label?

烈酒焚心 提交于 2021-02-20 18:44:02
问题 how can i change the fore color of the chart labels? here's a screenshot of the chart i tried using the chart1.series[0].FontForeColor = color.white; but the entire chart turns white. 回答1: Try this: this.chart1.BackColor = Color.AliceBlue; this.chart1.ChartAreas[0].AxisX.LineColor = Color.Red; this.chart1.ChartAreas[0].AxisX.MajorGrid.LineColor = Color.Red; this.chart1.ChartAreas[0].AxisX.LabelStyle.ForeColor = Color.Red; this.chart1.ChartAreas[0].AxisY.LineColor = Color.Red; this.chart1

How to parametrize a xunit class fixture?

别等时光非礼了梦想. 提交于 2021-02-20 18:42:29
问题 xUnit offers the concept of (shared) class fixtures as explained in Shared Context between Tests. What I didn't figure out so far is if there is a way of parametrizing such class fixtures. For example, what if the DatabaseFixture should be enriched with some test data which depends on the test it's being run against? A test class might want to insert test data but only once and then run all its tests against that database (fixture). In other words, what if the // ... initialize data in the

How to Close SafeFile Handle properly

二次信任 提交于 2021-02-20 18:12:24
问题 I am working on a c# project where i communicate with an USB device. I open the connection with: [DllImport("Kernel32.dll", SetLastError = true)] static extern Microsoft.Win32.SafeHandles.SafeFileHandle CreateFile(string filename, [MarshalAs(UnmanagedType.U4)]FileAccess fileaccess, [MarshalAs(UnmanagedType.U4)]FileShare fileshare, int securityattributes, [MarshalAs(UnmanagedType.U4)]FileMode creationdisposition, int flags, IntPtr template); private Microsoft.Win32.SafeHandles.SafeFileHandle