Automatically incremented revision number doesn't show up in the About Box - vb.net

I have a small VB.NET application that I'm working on using the full version of Visual Studio 2005. In the Publish properties of the project, I have it set to Automatically increment revision with each publish.
The issue is that it's only incrementing the revision in the Setup files. It doesn't seem to be updating the version number in the About Box (which is the generic, built-in, About Box template). That version number seems to be coming from My.Application.Info.Version.
What should I be using instead so that my automatically incrementing revision number shows up in the about box?

Change the code for the About box to
Me.LabelVersion.Text = String.Format("Version {0}", My.Application.Deployment.CurrentVersion.ToString)
Please note that all the other answers are correct for "how do I get my assembly version", not the stated question "how do I show my publish version".

It took me a second to find this, but I believe this is what you are looking for:
using System;
using System.Reflection;
public class VersionNumber
{
public static void Main()
{
System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly();
Version version = assembly.GetName().Version;
Console.WriteLine ("Version: {0}", version);
Console.WriteLine ("Major: {0}", version.Major);
Console.WriteLine ("Minor: {0}", version.Minor);
Console.WriteLine ("Build: {0}", version.Build);
Console.WriteLine ("Revision: {0}", version.Revision);
Console.Read();
}
}
It was based upon the code provided at the following site - http://en.csharp-online.net/Display_type_version_number

I'm no VB.NET expert, but have you tried to set the value to for example 1.0.0.*?
This should increase the revision number (at least it does in the AssemblyInfo.cs in C#).

The option you select is only to update the setup number. To update the program number you have to modify the AssemblyInfo.
C#
[assembly: AssemblyVersion("X.Y.")]
[assembly: AssemblyFileVersion("X.Y.")]
VB.NET
Assembly: AssemblyVersion("X.Y.*")

It's a maximum of 65535 for each of the 4 values, but when using 1.0.* or 1.0.*.*, the Assembly Linker will use a coded timestamp (so it's not a simple auto-increment, and it can repeat!) that will fit 65535.
See my answer to this question for more links and details.

Related

Retrieve version number from another exe [duplicate]

Salvete! I am writing a vb.net program to update the readme files for my applications. I want to extract the version number from other compiled applications. I want to read the version number from the executable, not from its uncompiled resources.
How can I do this in vb.net without using an external tool like reshacker?
(I found this link, but it is for another language.)
You can use a function like this to do it:
Private Function GetFileVersionInfo(ByVal filename As String) As Version
Return Version.Parse(FileVersionInfo.GetVersionInfo(filename).FileVersion)
End Function
Usage:
Debug.WriteLine(GetFileVersionInfo("C:\foo\bar\myapp.exe").ToString)
Output:
4.2.9.281

Howto tell PowerBuilder to pass options to a JVM when starting?

What I want to do?
I want to create and consume java objects in PowerBuilder and call methods on it. This should happen with less overhead possible.
I do not want to consume java webservices!
So I've a working sample in which I can create a java object, call a method on this object and output the result from the called method.
Everything is working as expected. I'm using Java 1.8.0_31.
But now I want to attach my java IDE (IntelliJ) to the running JVM (started by PowerBuilder) to debug the java code which gets called by PowerBuilder.
And now my question.
How do I tell PowerBuilder to add special options when starting the JVM?
In special I want to add the following option(s) in some way:
-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005
The JVM is created like following:
LONG ll_result
inv_java = CREATE JavaVM
ll_result = inv_java.CreateJavaVM("C:\Development\tms java\pbJavaTest", FALSE)
CHOOSE CASE ll_result
CASE 1
CASE 0
CASE -1
MessageBox ( "", "jvm.dll was not found in the classpath.")
CASE -2
MessageBox ( "", "pbejbclient90.jar file was not found." )
CASE ELSE
MessageBox ( "", "Unknown result (" + String (ll_result ) +")" )
END CHOOSE
In the PowerBuilder help I found something about overriding the static registry classpath. There is something written about custom properties which sounds like what I'm looking for.
But there's no example on how to add JVM options to override default behavior.
Does anyone have a clue on how to tell PowerBuilder to use my options?
Or does anyone have any advice which could guide me in the right direction?
Update 1
I found an old post which solved my initial issue.
If someone else want to know how it works take a look at this post:
http://nntp-archive.sybase.com/nntp-archive/action/article/%3C46262213.6742.1681692777#sybase.com%3E
Hi, you need to set some windows registry entries.
Under HKEY_LOCAL_MACHINE\SOFTWARE\Sybase\Powerbuilder\9.0\Java, there
are two folders: PBIDEConfig and PBRTConfig. The first one is used when
you run your application from within the IDE, and the latter is used
when you run your compiled application. Those two folders can have
PBJVMconfig and PBJVMprops folders within them.
PBJVMconfig is for JVM configuration options such as -Xms. You have to
specify incremental key values starting from "0" by one, and one special
key "Count" to tell Powerbuilder how many options exists to enumerate.
PBJVMprops is for all -D options. You do not need to specify -D for
PBJVMProps, just the name of the property and its value, and as many
properties as you wish.
Let me give some examples:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Sybase\PowerBuilder\9.0\Java\PBIDEConfig\PBJVMprops]
"java.security.auth.login.config"="auth.conf"
"user.language"="en"
[HKEY_LOCAL_MACHINE\SOFTWARE\Sybase\PowerBuilder\9.0\Java\PBRTConfig\PBJVMconfig]
"0"="-client"
"1"="-Xms128m"
"2"="-Xmx512m"
"Count"="3"
[HKEY_LOCAL_MACHINE\SOFTWARE\Sybase\PowerBuilder\9.0\Java\PBRTConfig\PBJVMprops]
"java.security.auth.login.config"="auth.conf"
"user.language"="en"
Regards,
Gokhan Demir
But now there's another issue...
PB isn't able to create EJB Proxies for my sample class which is really simple with java 1.8.0_31. They were created with the default version, which is 1.6.0_24.
public class Simple
{
public Simple()
{
}
public static String getValue()
{
return "blubber";
}
public int getInt32Value()
{
return 123456;
}
public double getDoubleVaue()
{
return 123.123;
}
public static void main(String[] args)
{
System.out.println(Simple.getValue());
}
}
The error is the following. :D
---------- Deploy: Deploy of project p_genapp_ejbclientproxy (15:35:18)
Retrieving PowerBuilder Proxies from EJB...
Generation Errors: Error: class not found: (
Deployment Error: No files returned for package/component 'Simple'. Error code: Unknown. Proxy was not created.
Done.
---------- Finished Deploy of project p_genapp_ejbclientproxy (15:35:19)
So the whole way isn't a option because we do not want to change the JAVA settings in PB back and forth just to generate new EJB Proxies for changed JAVA objects in the future...
So one option to test will be creating COM wrappers for JAVA classes to use them in PB...

What should one return other than success for a custom Action

I am trying my hand at writing my first Custom Action for an installer (built with Advanced Installer) using the VB Custom Action Project template supplied with the WiX Toolset. Essentially I just want to test the amount of Ram on a machine to determine which version of a prerequisite ought to be installed if not already present.
What I have so far (in semi pseudo code) is the following;
Public Class CustomActions
<CustomAction()> _
Public Shared Function CustomAction1(ByVal session As Session) As ActionResult
session.Log("Begin CustomAction1")
If New Microsoft.VisualBasic.Devices.ComputerInfo().TotalPhysicalMemory > [ram size here] Then
Return ActionResult.Success
Else
Return ActionResult.SkipRemainingActions
End If
End Function
End Class
What I would like to know is if returning ActionResult.SkipRemainingActions is the correct choice to use if the ram on the machine being tested is less than the result that prompts success.
Here's my 2 cents on this... If the condition isn't met, I would terminate the install. If you use what you have then the install will still continue/skip per say and it actually would skip all other conditions. When you use "ActionResult.Failure" this will roll back the installation.
I would use. . .
Return ActionResult.Failure
On a side note, I would wrap this up in a Try/Catch and throw a message . . .
This is the wrong question to answer (though I agree with the answer of ActionResult.Failure for it).
The right question is what is the best way to check for total available memory in Windows Installer. Per the Windows Installer Property Reference, the answer is to compare against PhysicalMemory, and the right place to do this is in a Condition element, not in a custom action.

Can I use a regular System.dll in a Compact Framework project?

In my test Winforms app (in which I'm targeting .NET 3.5, to simulate the Windows CE / Compact Framework 3.5 app that this is a first-line test for as much as possible), I added some JSON.NET code to deserialize json returned from WebAPI methods:
try
{
const string uri = "http://localhost:48614/api/departments";
var webRequest = (HttpWebRequest)WebRequest.Create(uri);
var webResponse = (HttpWebResponse)webRequest.GetResponse();
if ((webResponse.StatusCode == HttpStatusCode.OK) && (webResponse.ContentLength > 0))
{
var reader = new StreamReader(webResponse.GetResponseStream());
string s = reader.ReadToEnd();
MessageBox.Show(string.Format("Content from HttpWebRequest is {0}", s));
var arr = JsonConvert.DeserializeObject<JArray>(s);
int i = 1;
foreach (JObject obj in arr)
{
var id = (string)obj["Id"];
var accountId = (double)obj["AccountId"];
var departmentName = (string)obj["DeptName"];
MessageBox.Show(string.Format("Object {0} in JSON array: id == {1}, accountId == {2}, deptName == {3}", i, id, accountId, departmentName));
i++;
}
}
else
{
MessageBox.Show(string.Format("Status code == {0}", webResponse.StatusCode));
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
...This runs fine in the .NET 3.5 Winforms app, but when I copied it over to the Windows CE-targetted app, the code wouldn't run, with the following errors spilling forth:
The type 'System.ComponentModel.IBindingList' is defined in an assembly that is not referenced. You must add a reference to assembly 'System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
The type 'System.ComponentModel.ITypedList' is defined in an assembly that is not referenced. You must add a reference to assembly 'System, Version=2.0.0.0...
The type 'System.ComponentModel.INotifyPropertyChanging' is defined in an assembly that is not referenced....
The type 'System.ComponentModel.ICustomTypeDescriptor' is defined in an assembly...
The type 'System.ComponentModel.INotifyPropertyChanged' ...
The type 'System.Uri'...
I saw that in the Winforms (testbed) app, I'm using version 2.0.0.0 of the "regular" (or "deluxe" when compared to CF) System.dll. In the Windows CE app, though, I was using the CF flavor of version 3.5 found here:
C:\Program Files (x86)\Microsoft.NET\SDK\CompactFramework\v3.5\WindowsCE\System.dll
I tried using version 2 CF from C:\Program Files (x86)\Microsoft.NET\SDK\CompactFramework\v2.0\WindowsCE\System.dll, but that failed, too - so it's apparently not really the version (3.5 vs. 2.0), but the "flavor" (CF vs "deluxe"/regular System.dll).
SO...I replaced the CF-flavored System.dll[s] with the one successfully used by the Winforms test app, explicitly the one in C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.dll (I have no System.dll in C:\Windows\Microsoft.NET\Framework\v3.5, anyway).
It no longer gives those same err msgs as listed above, but there is another compile error that may (or may not be) related (Can I give an emulator more disk space?) now.
Whether it is or not (related), it brings up the intriguing question: Will using a regular System.dll in a Windows CE project cause a problem?
If it will -- or there's a good chance that it will -- cause a problem, since it was apparently the JSON.NET code that required the change to an "off-colored" version of System.dll, is there a CF-ready / CF-specific version of JSON.NET? Will I have to create my own CF-targeted version of an assembly from the JSON.NET source?
UPDATE
In the JSON.NET readme, it states:
For a Compact Framework 3.5 build download Json.NET 3.5.
Which I assumed meant the .DLL in \Json50r7\Bin\Net35
Am I wrong about that?
UPDATE 2
When I attempt to open Newtonsoft.Json.Net35.sln in Windows 2008, with the intention of creating a CE-targeted assembly, it doesn't allow me, saying, "The selected file is a solution file, but was created by a newer version of this appllication and cannot be opened*"
It also says in the JSON.NET read me:
Microsoft stopped support for the Compact Framework in Visual Studio 2010.
...so I don't think I can open it in a newer version of VS2008 and create a CF-friendly DLL, either...
UPDATE 3
Looking for a "Compact" folder in the download from http://json.codeplex.com/releases/view/113546, but I see no such folder:
It's not the "Portable" folder, is it?
As Robert Harvey suggests, the tile and the actual question here don't match. You probably should fix that.
The answer to the current title "Can I use a regular System.dll in a Compact Framework Project?" is absolutely, definitively no. You cannot mix and match. Full-framework assemblies cannot run under the Compact Framework. There's no way to make them work. Period. Stop trying this.
The answer to "How do I use JSON.NET is a Compact Framework Project" is that you should go to the JSON.NET project site on GitHub and specifically look at the last JSON.NET 3.5 release (it was Release 8) and download it. Inside that zip file is a folder named "Compact" that contains an assembly named Newtonsoft.Json.Compact.dll. Add a reference to that DLL to your Compact Framework 3.5 project.

SubSonic throwing 'System.IndexOutOfRangeException' when in Visual Studio Debug mode

I recently inherited the code set for a Product I now own which uses Subsonic 2.1.0 to perform its data-access.
When I go in to debug said code set, all that I get in the Output window of Visual Studio 2010 is the following (for pretty much every column of every object trying to be loaded):
A first chance exception of type 'System.IndexOutOfRangeException' occurred in System.Data.dll
This is the block of code where it is blowing up in Subsonic, which is located in the SubSonic.RecordBase class, which looks like so:
/// <summary>
/// Loads the object with the current reader's values. Assumes the reader is already moved to
/// first position in recordset (aka has been "Read()")
/// </summary>
/// <param name="dataReader">The data reader.</param>
public virtual void Load(IDataReader dataReader)
{
foreach(TableSchema.TableColumn col in BaseSchema.Columns)
{
try
{
SetColumnValue(col.ColumnName, dataReader[col.ColumnName]);
}
catch(Exception)
{
// turning off the Exception for now
// to support partial loads
// throw new Exception("Unable to set column value for " + col.ColumnName + ": " + x.Message);
}
}
SetLoadState();
MarkClean();
}
The offending line in there is:
SetColumnValue(col.ColumnName, dataReader[col.ColumnName]);
col.ColumnName doesn't match anything in the dataReader at this point. It's almost like it's using an old/prior dataReader to attempt to pull data from.
I'm hoping someone else has encountered this issue, as I'm still fairly new to Subsonic and have only used Hibernate in the past for an ORM.
This happens on both my older machine and a new one I just built, both running Windows 7 Professional x64 w/ Visual Studio 2010 Professional as the IDE.
I've gone through the forums, Google, and many other sites out there, but have yet to find anyone else encountering this issue.
If more information is required, please let me know and I'll be happy to post!
Thanks in advance!
Justin
After spending a while longer looking into this issue, I've realized that it's intentionally throwing these Exceptions for the sake of "partially loading" a data object when only certain fields are being retrieved from the database and mapped to the data object itself. (e.g. just supresses the Exceptions itself and resumes if it can't map a column's data properly.
Not sure if this was originally part of the SubSonic code or something that was introduced by those before me.
Thanks again!
Justin
It looks like the DB Schema may have changed since the SubSonic objects where last created.