|
Is it possible to pull from somewhere after the application has been compiled to know what it's build version number is so I can show it in a label? I am thinking I can pull if from the assembly but my attempts have failed. Please can someone point me in the right direction?
Here is what I am currently doing and it does not match the build version of the application that I am compiling.
lblAppVersion.Text = "Version: " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString() + " or " + System.Reflection.Assembly.GetCallingAssembly().GetName().Version.ToString();
|
|
|
|
|
Are you looking for something like this?
labelControlVersion.Text = string.Format ( "Version: {0}", Assembly.GetExecutingAssembly ( ).GetName ( ).Version ) ;
|
|
|
|
|
Not quite I want the applications build version... which would show on the project properties screen under the publish tab.
any idea where this is?
|
|
|
|
|
What do you want the text in the label to look like?
To Get This "Ver. 5.1.2 Rev. 3"
Try like this;
Dim avi As System.Version = System.Reflection.Assembly.GetExecutingAssembly.GetName.Version
lblVersion.Text = "Ver. " & Format(avi.Major, "###0").TrimEnd & "." _
& Format(avi.Minor, "###0").TrimEnd & "." & Format(avi.Build, "###0").TrimEnd _
& " Rev. " & Format(avi.Revision, "###0")
Of course this is not the publish version (just saw last post)
|
|
|
|
|
it is very easy tog et this info
This is a code for this
Version v = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
lblVersion.Text = v.ToString();
This information is stored in the AssemblyInfo.cs under Node 'Properties' in Solution explorer!
Reg,
Deep
Happy Coding!
|
|
|
|
|
Thanks I learned that c# does not auto increment the version per each build. That was the issue I was having.
|
|
|
|
|
I am having a problem changing the forecolor of a DataGridView header. I have tried the following code:
dgvMaintenance.EnableHeadersVisualStyles = false;
DataGridViewCellStyle dgvcs = dgvMaintenance.ColumnHeadersDefaultCellStyle;
dgvcs.BackColor = System.Drawing.Color.DarkGray;
dgvcs.ForeColor = System.Drawing.Color.White;
The backcolor changes, but the forecolor does not.
I have also tried:
dgvMaintenance.EnableHeadersVisualStyles = false;
DataGridViewCellStyle dgvcs = new DataGridViewCellStyle();
dgvcs.BackColor = System.Drawing.Color.DarkGray;
dgvcs.ForeColor = System.Drawing.Color.White;
dgvMaintenance.ColumnHeadersDefaultCellStyle = dgvcs;
with the same results. I have also added code to change the font and that works too.
What am I doing incorrectly? Thank you for any help.
modified on Wednesday, August 5, 2009 12:26 PM
|
|
|
|
|
i need to check that the content in a textbox is a 6-digit hexadecimal number (or rather, an HTML color code).
How do I do this?
|
|
|
|
|
You could use a regular expression.
There's a bunch of regular expression classes in .net (Start here[^]
If you don't know about regular expressions, you might want to read up a bit on them. There's a site here[^] that's worth looking at.
It's also worth having a tool to test them with before you start coding them. A popular one is Expresso[^].
Simon
|
|
|
|
|
use this function...
bool ValidateColor(string s)
{
if(s.Length != 6)
return false;
for(int i = 0; i < 6; i++)
{
int c = (int)s[i];
if(!(c > 47 && c < 58) || !(c > 64 && c < 71))
return false;
}
return true;
}
..should do the job
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
That is terrible. I see magic constants, a major bug (|| instead of &&) and no acceptance of lower-case hex.
I would suggest:
public static bool ValidateColor(string s, out int value) {
return s!=null && s.Length==6 && int.TryParse(s, out value, NumberStyles.HexNumber);
}
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Yeah, my bad... I wanted to use the parse method but couldn't remember the param for the the NumberStyles bit...
Plus I knew you be around to set me straight
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
I want to do the program in c# which is form based,
This is what my program have to do,
It should monitor for the internet explorer, when it is opened it should show a message box. and whenever the url changes in it should be displayed in message box. The url here changed by user.
I dont know how to add beforenaviagte2 event to each ie window,
Where there is a will there is a way
-MS
|
|
|
|
|
No replies...??
Where there is a will there is a way
-MS
|
|
|
|
|
|
Article
Internet Explorer Activity Monitor[^]
The demo project worked fine which contains an exe.
WHen I am opening source code project in my visual studio 2008..After Conversion process, I run it..But it not worked for me.
Please help me to fix this. I am new to c#.
Where there is a will there is a way
-MS
|
|
|
|
|
I have a number of functions that, for one reason or another, return data type object.
If I try and use the + operand (or indeed any arithmetic operator) on types object the compiler throws a wobbly.
How do I tell if a given object supports the "+" operator and, if it does, invoke that "+" operator?
|
|
|
|
|
Hi,
I don't think returning a general object is a good choice.
Have you considered returning a small class or struct holding both the value and the type of the result?
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Unfortunately it is for evaluating an expression tree so we don't know until we are running what an expression will evaluate to.
I have found that the compiuler turns operator + to a method op_Addition so i guess I need to do a GetMethod("op_Addition")?
|
|
|
|
|
I can't answer that, I don't know enough of your problem domain.
I would refrain from relying on undocumented but observed compiler behavior whenever possible.
I do know when I create an interpreter/parser-like system, I use small data structures to describe what I am dealing with, i.e. something holding name, value, type, etc.
Then when some operator needs executed, its code can check its operands' types and act accordingly.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Nope, that would require an interface. MS could probably write generic interfaces to do that, but I don't think they'd apply them to the built-in types retroactively.
P.S. You might want to see what I did here[^].
|
|
|
|
|
Hi,
I have a problem to get single numeric values from an Excel worksheet (that I need to process as I receive it). I use the Microsoft Excel 9.0 Library because I need to process EXcel 2000/2003 files.
This is the range:
Excel.Range CellRange = (Excel.Range) WS.Cells[RowNum, ColNum];
I use this statement to check format and cell.
MessageBox.Show(CellRange.NumberFormat.ToString() + "\n" + RowNum.ToString() + "\n" + ColNum.ToString());
Only in case of format 0.0 I can get a value (e.g. 234.9) like this:
Result = Convert.ToDouble(CellRange.Value);
MessageBox.Show(Result.ToString());
But the format can also be General with values e.g. 234.9 (with point), 234,9 (with comma) or 2349 (without separator).
It must be simple, but I can't find the solution.
Who can help me?
Thanks,
Gijs
|
|
|
|
|
Convert.ToDouble("34.13", CultureInfo.InvariantCulture);
There's also a CurrentCulture
I are Troll
|
|
|
|
|
Yes, the CultureInfo helps in certain cases.
But I don't manage to get a value (string or numeric) from a cell with type 'General'.
The single cell range 'Value' is null, although the Excel cell contains a few characters.
Thanks,
Gijs
|
|
|
|
|
Hello,
I am writing a server/client application and I have encountered a weird problem. The server handles several TCP connections and sometimes sends messages to the clients. Now, if I send these messages too "fast" they are not sent at all. However, if a Thread.Sleep(1000); command is introduced before sending a message everything works fine (except it is very slow). Maybe it is relevant that the Send() method is called by different threads , triggered by events (locking the communication object does not help). Here is the code:
public void Send(int id, string message)
{
StreamWriter writer = new StreamWriter(connections_[id].GetStream());
writer.WriteLine(message);
writer.Flush();
}
|
|
|
|