Sysprep quick fix

| |

Sometime, sysprep operation may fail with the following error message:System Preparation Tool 3.14 A fatal error occurred while trying to sysprep the machine

Details can be found on Microsoft web site https://support.microsoft.com/en-us/kb/2769827 

The quick fix is available here

In run as administrator PowerShell

Import-Module Appx
Import-Module Dism

Get-AppxPackage -AllUser | Format-List PackageFullName

Copy the result in new text file.

in the result, replace "PackageFullName:" with "Remove-AppxPackage -Package"

Copy the edited rows and paste in power shell window

check is there any apps left
 

2016/08/09 19:43

Deploy ASP .NET MVC application using LocalDB to local IIS

| |

When ASP application is published to IIS using LocalDB accessing the database may result in the following error:

"

Server Error in '/Application_Name' Application.

2016/08/08 22:06

C# Custom control – TextBox accepting only numbers, decimal numbers, signed numbers

| | | | |

The creation of custom control using Visual Studio involves the following steps:

  1. Start Visual Studio;
  2. Create new “Windows Control Library” project;
  3. In the created project delete “User Control” file;
  4. Go to “Project” > “Add User Control” and give it a name;

    2016/07/29 21:38

Visual Studio – Add custom control DLL to toolbox

| |

To add a custom control to VisualStudio project:

1) Go to “Toolbox” tab;
2) Right click on it and click “Choose Items…”;

3) In the “Choose Toolbox Items” window click on the “Browse…” button.
Navigate to the location where your Dynamic Link Library (DLL) file is.
Click “OK”.

2016/07/28 21:17

C# - How to add reference to project

| |

To add a reference to CSharp project do the following:

1) Open “Solution Explorer”;
2) Right click “References”;
3) Choose “Add Reference”.

On the Reference Manager Window go to: “Assemblies” -> “Framework”. In the list find the reference you need, select it and checkup the checkbox in front it. Then select “OK”.

2016/07/27 18:23

C# Textbox - enter only positive numbers on KeyPress event in Windows form application

| | |

To prevent users from entering incorrect data in Windows form application, set restriction to allow only specific characters to be entered in the text box.

This example uses KeyPress event to monitor the users input and to apply the restriction required.

2016/07/22 18:16

C# How to draw shapes – Circle, Rectangle, Arc, Pie, Polygon, Bezier, Text

|

           

In order to draw shapes in C# a start point and end point coordinates, and a Pen control must be defined first.

Coordinates in C#
The value of x is the location of the point along the x-axis, the 0 is at the extreme left.

2016/07/22 17:43

C# - Get connection string from Web.config file

|

To get the connection string from the Web config file with CSharp code include the following using directive:

using System.Configuration;

Then create a string variable and assign the connection string like this:

string connStr = ConfigurationManager.ConnectionStrings["connectionString_Name"].ConnectionString;

If “ConfigurationManager” is not recognized you will need to add reference to: "System.Configuration".

2016/06/23 19:32

c# combobox set selected item by item's text

| | |

C# Combobox defined with name my_combobox

private System.Windows.Forms.ComboBox my_combobox;

Define string variable with the text of the combobox item that has to be selected. For example, if the combobox items have text values "item_a" "item_b" "item_c" ... and the item which text is "item_b" has to be selected

string select_this_item = "item_b";string item_text = "";  int i = 0;for (i = 0; i < my_combobox.Items.Count; i++) {    item_text = my_combobox.GetItemText(my_combobox.Items[i]);    if (item_text == select_this_item)    {       my_combobox.SelectedItem = (object)my_combobox.Items[i];       break;    }}

2016/05/04 23:10

c# passing data between forms

| |

In C# project with two forms

public partial class Form1 : Form <- this is the main form

public partial class Form2 : Form <- this is the second form

To pass variables (values, data) from Form1 to Form2

Case: public variables in Form2

public string input_variable; <- put this in Form2 as global variable

public string output_variable; <- put this in Form2 as global variable

in Form1 inside the function that run (call) Form2

Form2 form = new Form2();

form.input_variable= "some string data"; <- send the input_variable from Form1 to Form2

DialogResult result = form.ShowDialog();

if (result == DialogResult.OK)

{

public string local_variable = form.output_var

2016/05/04 20:43