*** Update - Since I made this post, I have found another tool that is simpler to use and also work with VS2010. See this http://autobuildversion.codeplex.com/
If this doesn't work for you, then you may with to view the info below:
The Setup and Deployment (Windows Installer) has a significant change between VS2005 and VS2008. In VS2008, a file will not be updated by the installer if the File Version has not changed. This pretty much breaks all of the VS2005 Installations I have created. There are various reasons for this, and I will let you read for yourself:
http://www.microsoft.com/communities/newsgroups/en-us/default.aspx?dg=microsoft.public.vstudio.general&tid=c4c56abf-9bde-45ed-8737-90cf90514d89&cat=&lang=&cr=&sloc=&p=1
The solution to the problem is to increment the File Version (under Project Properties/Assembly Information) between Setup (.msi) builds. So, before every setup you create, you have to go manually update the File Version so the setup will update the file. Before, you just had to update the Version property in the Installer Project (and let it update the Product Code); you still have to do this (which is probably acceptable). I thought there must be someway to automatically increment the File Version since this change to the Installer breaks all of my setups; however, there is not (that I can find anyway). The only workable solution I have found is to use a BuildTask that updates the AssemblyInfo.vb (or AssemblyInfo.cs) before each build is made. This solution is a really complicated for something that was a checkbox in VB6 (as someone pointed out).
Here is the solution I tried and it does work:
http://www.codeproject.com/KB/dotnet/Auto_Increment_Version.aspx
Here is a similar solution:
http://weblogs.asp.net/bradleyb/archive/2005/12/02/432150.aspx
This blog is a depository for things I have found regarding VB.NET and C#.NET development (and other things I may need to remember). This blog is primarily for my own reference, but if the information I found is useful to others, then that is great. If others want to contribute with comments or other information, then that is great too.
Thursday, September 4, 2008
Wednesday, September 3, 2008
Launch Internet Explorer or Default Browser from VB.NET (or C#)
I found several ways to launch IE from VB.NET, but the following approach appears to be the simplest:
Process.Start("IExplore.exe", "http://dotnetref.blogspot.com")
More information at:
http://bytes.com/forum/thread413370.html
If you want to launch the default browser (such as Firefox), it may be easiest to just say the following:
Process.Start("http://dotnetref.blogspot.com")
and let the Shell do the work of deciding th default browser.
For more info on this approach:
http://www.vbforums.com/showthread.php?t=323257
The C# approach is not any different, just use the approprate syntax.
Process.Start("IExplore.exe", "http://dotnetref.blogspot.com")
More information at:
http://bytes.com/forum/thread413370.html
If you want to launch the default browser (such as Firefox), it may be easiest to just say the following:
Process.Start("http://dotnetref.blogspot.com")
and let the Shell do the work of deciding th default browser.
For more info on this approach:
http://www.vbforums.com/showthread.php?t=323257
The C# approach is not any different, just use the approprate syntax.
Labels:
default browser,
Internet Explorer,
launching
Thursday, August 28, 2008
Getting a Device ID using the Compact Framework
Here are a couple of approaches I found for getting a Device ID using the compact framework. Both are lengthy solutions to something that should probably be built into platform.
http://msdn.microsoft.com/en-us/library/ms172516.aspx
http://msdn.microsoft.com/en-us/library/aa446562.aspx
http://blogs.msdn.com/jehance/archive/2004/07/12/181067.aspx
http://msdn.microsoft.com/en-us/library/ms172516.aspx
http://msdn.microsoft.com/en-us/library/aa446562.aspx
http://blogs.msdn.com/jehance/archive/2004/07/12/181067.aspx
Labels:
device Id,
Windows Mobile
How to do a CDC.Escape() in .NET
There may be ways around using the old CDC Escape function from MFC, but when you are porting C++ to C#, it is nice to just call the same Win32api functions that you were using before. For printing, I used the Escape function to get information about the printer, but since this method can return a Point structure the PInvoke was more difficult. Here is the code necessary to call the Escape method:
First you need the POINT structure defined in .NET:
[StructLayout(LayoutKind.Sequential)]
public struct POINT
{
public int X;
public int Y;
public POINT(int x, int y)
{
this.X = x;
this.Y = y;
}
}
Then you need the Signature for the Escape method ):
[DllImport("gdi32.dll")]
private static extern int Escape(IntPtr hdc, int nEscape, int cbInput, string lpvInData, IntPtr lpvOutData);
There are also the constants that are sent as the Escape type (I just provide a couple of example that return a Point structure):
private const int GETPRINTINGOFFSET = 13;
private const int GETPHYSPAGESIZE = 12;
Then you can call the method. You can get the Graphics object from various places, but you need the HDc from it regardless:
IntPtr hDC = e.Graphics.GetHdc();
IntPtr pnt;
long stat;
POINT printingOffsetPoint = new POINT(0,0);
pnt = Marshal.AllocHGlobal(Marshal.SizeOf(printingOffsetPoint));
Marshal.StructureToPtr(printingOffsetPoint, pnt, false);
stat = Escape(hDC,GETPRINTINGOFFSET, 0, null, pnt);
printingOffsetPoint = (POINT)Marshal.PtrToStructure(pnt, typeof(POINT));
Marshal.FreeHGlobal(pnt);
POINT physPageSizePoint = new POINT(0, 0);
pnt = Marshal.AllocHGlobal(Marshal.SizeOf(physPageSizePoint));
Marshal.StructureToPtr(physPageSizePoint, pnt, false);
stat = Escape(hDC, GETPHYSPAGESIZE, 0, null, pnt);
physPageSizePoint = (POINT)Marshal.PtrToStructure(pnt, typeof(POINT));
Marshal.FreeHGlobal(pnt);
First you need the POINT structure defined in .NET:
[StructLayout(LayoutKind.Sequential)]
public struct POINT
{
public int X;
public int Y;
public POINT(int x, int y)
{
this.X = x;
this.Y = y;
}
}
Then you need the Signature for the Escape method ):
[DllImport("gdi32.dll")]
private static extern int Escape(IntPtr hdc, int nEscape, int cbInput, string lpvInData, IntPtr lpvOutData);
There are also the constants that are sent as the Escape type (I just provide a couple of example that return a Point structure):
private const int GETPRINTINGOFFSET = 13;
private const int GETPHYSPAGESIZE = 12;
Then you can call the method. You can get the Graphics object from various places, but you need the HDc from it regardless:
IntPtr hDC = e.Graphics.GetHdc();
IntPtr pnt;
long stat;
POINT printingOffsetPoint = new POINT(0,0);
pnt = Marshal.AllocHGlobal(Marshal.SizeOf(printingOffsetPoint));
Marshal.StructureToPtr(printingOffsetPoint, pnt, false);
stat = Escape(hDC,GETPRINTINGOFFSET, 0, null, pnt);
printingOffsetPoint = (POINT)Marshal.PtrToStructure(pnt, typeof(POINT));
Marshal.FreeHGlobal(pnt);
POINT physPageSizePoint = new POINT(0, 0);
pnt = Marshal.AllocHGlobal(Marshal.SizeOf(physPageSizePoint));
Marshal.StructureToPtr(physPageSizePoint, pnt, false);
stat = Escape(hDC, GETPHYSPAGESIZE, 0, null, pnt);
physPageSizePoint = (POINT)Marshal.PtrToStructure(pnt, typeof(POINT));
Marshal.FreeHGlobal(pnt);
Thursday, August 7, 2008
Using Dock Fill on a Control when you have a Menu and/or Status Bar
I have long been frustrated in Visual Studio .NET when I try to use a control's Dock property set to Fill and also have a Menu or Status bar on the same form. The Docked control typically fills to the form and is not the right size (not accounting for the size of the Menu or Status bar).
It turns out that there is a very simple (but not very obvious) solution to this problem. Taken from Alex Fr's response to a comment on a similar problem:
"Actually, all you need to do is rightclick the panel and choose "bring to front", the dock layout logic handles each component in order so when it reaches your panel first it doesnt know it has other components that fill up other parts of the container with their docking settings. "
Just make sure the Docked control is in front of the menu and status bar and it works as you would expect.
It turns out that there is a very simple (but not very obvious) solution to this problem. Taken from Alex Fr's response to a comment on a similar problem:
"Actually, all you need to do is rightclick the panel and choose "bring to front", the dock layout logic handles each component in order so when it reaches your panel first it doesnt know it has other components that fill up other parts of the container with their docking settings. "
Just make sure the Docked control is in front of the menu and status bar and it works as you would expect.
Labels:
Dock,
Fill,
Menu,
Status Bar
Sunday, August 3, 2008
Seeing what color the .NET Color names actually are
I found a very useful .NET Color reference at the following web site. If you want to compare AliceBlue, DodgerBlue, and SteelBlue, here is an easy way to do it:
http://www.opinionatedgeek.com/DotNet/Tools/Colors/default.aspx
http://www.opinionatedgeek.com/DotNet/Tools/Colors/default.aspx
Wednesday, July 30, 2008
Setting the Form Icon to an Application Resource in VB.NET
I have an application with a main form and many dialogs. I want the main form and all of the dialogs to use the same icon in the forms' title bars. So, instead of defining the Icon property on each form, I have created an application resource and added a line of code to each Form_Load method.
First, add an Icon to your Project Resources (Project/Properties then on the Resource tab). Remember the name of the icon resource you create. Mine is AppIcon in this example.
Then for each Form_Load method in the VB.NET app (for the main form and each dialog's form), I add the following:
Me.Icon = My.Resources.AppIcon
There may be even better ways to do this, but this is the simplest I have found so far.
For more information on using resources, see:
http://visualbasic.about.com/od/usingvbnet/a/ResVBNET.htm
First, add an Icon to your Project Resources (Project/Properties then on the Resource tab). Remember the name of the icon resource you create. Mine is AppIcon in this example.
Then for each Form_Load method in the VB.NET app (for the main form and each dialog's form), I add the following:
Me.Icon = My.Resources.AppIcon
There may be even better ways to do this, but this is the simplest I have found so far.
For more information on using resources, see:
http://visualbasic.about.com/od/usingvbnet/a/ResVBNET.htm
Subscribe to:
Posts (Atom)