Wednesday, December 12, 2012

Automatically Increment Version number for Assembly

I have to look this up every time I do it, so I am posting this link to make it easier to find.


http://www.csharpcity.com/2012/visual-studio-automatic-version-numbering/



To summarize, you have to change the C# assemblyinfo.cs file from:

[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]


to just:

[assembly: AssemblyVersion("1.0.*")]
 
 
The AssemblyFileVersion entry must not be present. 
 
The version only increments when the project is opened, so it may appear that the version does not increment.
 
 
For VB.NET it is similar.   Edit the assemblyInfo.vb file and change:
 
 
 
 
 
to:
 
  


The GUI for Assembly Version does not let you make this change.

Tuesday, November 27, 2012

Closing Parent Form from Child Form in VB.NET

The Application.Exit() call can be made in the child form's FormClosed event to exist the app when the child form is closed.


    Private Sub Form_Child_FormClosed(sender As Object, e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed

        Application.Exit()

    End Sub

Unload Event equivalent in VB.NET



For VB.NET, you can use the FormClosed or FormClosing in place of the VB6 Unload event.

Tuesday, April 3, 2012

Can't find Mime Types in IIS 7.5

I was installing a Web Application on IIS 7.5. Everything seems to work until I try to visit some of my pages and they just didn't do anything, no error messages or anything. Strangely, all of the .aspx files worked, it was just simple files like .htm and .jpb that didn't work.

I thought maybe the Mime types were not setup correctly, so I went to see what was defined. I couldn't find the Mime Types option in the IIS Managment Console.

It turns out that the Static Content option under the Http Features (under Server Managers, Web Server roles) was not installed. Installed the Static Content option in Server Manager and everything started working.

Wednesday, November 16, 2011

My.Resources in C#

The equivalent of:

My.Resources

in VB.NET is:

Properties.Resources

in C#.

So,

Me.Icon = My.Resources.AppIcon

in VB.NET is equivalent to:

this.Icon = Properties.Resources.App_Icon;

in C#.

Friday, October 21, 2011

Computing RGB composite Color Value in C#

If you still have to deal with the Win32Api in C#, you may need to get the old-style RGB composite color values from a .NET Color value. The ToArgb method doesn't work like you want, so it has to be computed:

  private int ConvertColorToRGB(Color col)
    {
    return (col.R) | (col.G << 8) | (col.B << 16);
    }
 
If you are using VB.NET, it still has an RGB function to call or:

   Public Function ConvertColorToRGB(col As Color) As Integer

        Return CInt(col.R) Or (CInt(col.G) << 8) Or (CInt(col.B) << 16)

    End Function

Thursday, August 25, 2011

Updating the NUM_ROWS in USER_TABLES in Oracle

Good or bad, I use the NUM_ROWS values in the USER_TABLES table to help filter lists of tables when presenting them to the user. If I have a database and only about 25% of tables have records (and there are thousands of tables), then it is a lot nicer to only sift through the tables that do have records, and knowing how many records is even better (even if it is only an estimate). My problem is that these values don't just get updated automatically for you. You might find that they are all 0 even when there is data present. You can update all of the values with something like this:

exec dbms_stats.gather_schema_stats('mySchema', cascade=>TRUE)

A lot more info on this topic can be found at:

http://www.dba-oracle.com/concepts/tables_optimizer_statistics.htm