Tool to wrap up HTML for publishing in the post
http://centricle.com/tools/html-entities/
Thursday, 26 June 2008
.Net Snippet Files
How to create a .Net Snippet.
<codesnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet"> <codesnippet format="1.0.0">
<header>
<title> My Snippet </title>
</header>
<snippet>
<references>
<reference>
<assembly>System.Windows.Forms.dll</assembly>
</reference>
</references>
<code language="CSharp">
<!--[CDATA[if (jo != null)]]-->
</code>
</snippet>
My Snippet
To add into your Code Snippets Manager
Useful links....
Create: http://msdn.microsoft.com/en-us/library/ms165394.aspx
Add to manager: http://msdn.microsoft.com/en-us/library/9ybhaktf.aspx
On the File menu, click New and then click File.
-
Click XML File and then click Open.
-
On the File menu, click Save
. -
In the Save as type box, select All Files (*.*).
-
In the File name box, enter a file name with the .snippet file name extension.
-
Click Save.
<codesnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet"> <codesnippet format="1.0.0">
<header>
<title> My Snippet </title>
</header>
<snippet>
<references>
<reference>
<assembly>System.Windows.Forms.dll</assembly>
</reference>
</references>
<code language="CSharp">
<!--[CDATA[if (jo != null)]]-->
</code>
</snippet>
My Snippet
To add into your Code Snippets Manager
-
In the Language list, select the language that you want to add a directory to.
-
Click Add. This opens the Code Snippets Directory window.
-
Select the directory that you want to add to the Code Snippets Manager and click OK.The directory will now be used to search for available code snippets.
Useful links....
Create: http://msdn.microsoft.com/en-us/library/ms165394.aspx
Add to manager: http://msdn.microsoft.com/en-us/library/9ybhaktf.aspx
Wednesday, 25 June 2008
Deploying Windows Applications
Quick guide.......
1. Open .Net project
2. Right click solution in the solution explorer
3. Add - New Project
4. Select setup and Deployment from Project Types
5. Select Setup Project
6. Enter relevant name
7. Right click Setup project
8. Add - Project Output - ok (all dependencies should appear)
9. Build Setup and Project
10. MSI installer is created in the setup project folder which has been created beside the main project application.
11. Run the installer to create the MSI.
For any other prerequisites that might be needed for the application right click on the setup project in the solution explorer, click prerequisites and check the prerequisites to install and then build the setup file.
For example we had a problem trying to deploy an Windows .Net 2005 application which had crystal reports included in it. To get round this the Crystal Reports for .Net Framework 2.0 prerequisites had to be checked (following the steps above). This then created an MSI for the Crystal Reports Framework in the setup folder. Once installed on the users machine the reports worked fine.
1. Open .Net project
2. Right click solution in the solution explorer
3. Add - New Project
4. Select setup and Deployment from Project Types
5. Select Setup Project
6. Enter relevant name
7. Right click Setup project
8. Add - Project Output - ok (all dependencies should appear)
9. Build Setup and Project
10. MSI installer is created in the setup project folder which has been created beside the main project application.
11. Run the installer to create the MSI.
For any other prerequisites that might be needed for the application right click on the setup project in the solution explorer, click prerequisites and check the prerequisites to install and then build the setup file.
For example we had a problem trying to deploy an Windows .Net 2005 application which had crystal reports included in it. To get round this the Crystal Reports for .Net Framework 2.0 prerequisites had to be checked (following the steps above). This then created an MSI for the Crystal Reports Framework in the setup folder. Once installed on the users machine the reports worked fine.
Wednesday, 11 June 2008
Getting the current User Name in Windows programming
Use this for getting the user name when building a windows application in DotNet. Done!
--------------------------------------------------
//Place this at the top, above your namespace declaration
using System.Security.Principal;
//In a specific event, place the following.
string a;
a = System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToString();
Monday, 9 June 2008
Using TryParse() in C#
When we are validating integer input, usually from a textbox, we need to make sure that the text is a valid integer before we set the properties in our class.
We would normally have done this using the following type of code:
try
{
SomeInt = Convert.ToInt32(tbSomeInt.Text);
}
catch (Exception ex)
{
MessageBox.Show("Some int must be a valid integer");
return;
}
By using a try catch in this manner we add quite a bit of overhead to the work that the .Net framework has to do for us. We can use the TryParse() method to get round this.
int intSomeInt;
if (int.TryParse(tbSomeInt.Text, out intSomeInt) == true)
{
//if the conversion succeded
csSomeClass._SomeInt= intSomeInt;
}
else
{
MessageBox.Show("Some int must be a valid integer");
return;
}
This avoids the overhead of using the try and will run faster. Please note that you cannot use a class property in the out parameter of the method and must use a variable as above.
Here is a link to another blog that I found useful.
We would normally have done this using the following type of code:
try
{
SomeInt = Convert.ToInt32(tbSomeInt.Text);
}
catch (Exception ex)
{
MessageBox.Show("Some int must be a valid integer");
return;
}
By using a try catch in this manner we add quite a bit of overhead to the work that the .Net framework has to do for us. We can use the TryParse() method to get round this.
int intSomeInt;
if (int.TryParse(tbSomeInt.Text, out intSomeInt) == true)
{
//if the conversion succeded
csSomeClass._SomeInt= intSomeInt;
}
else
{
MessageBox.Show("Some int must be a valid integer");
return;
}
This avoids the overhead of using the try and will run faster. Please note that you cannot use a class property in the out parameter of the method and must use a variable as above.
Here is a link to another blog that I found useful.
Subscribe to:
Posts (Atom)