spot7.org logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories

Setting the value of a constant or variable at build time


You could try this (tested it and worked for me)

Public NotInheritable Class
ApplicationInformation
    Private Sub New()
    End Sub
    ''' <summary>
    ''' Gets the executing assembly.
    ''' </summary>
    ''' <value>The executing
assembly.</value>
    Public Shared ReadOnly Property
ExecutingAssembly() As System.Reflection.Assembly
        Get
            Return If(m_executingAssembly,
(InlineAssignHelper(m_executingAssembly,
System.Reflection.Assembly.GetExecutingAssembly())))
        End Get
    End Property
    Private Shared m_executingAssembly As
System.Reflection.Assembly

    ''' <summary>
    ''' Gets the executing assembly version.
    ''' </summary>
    ''' <value>The executing assembly
version.</value>
    Public Shared ReadOnly Property
ExecutingAssemblyVersion() As System.Version
        Get
            Return If(m_executingAssemblyVersion,
(InlineAssignHelper(m_executingAssemblyVersion,
ExecutingAssembly.GetName().Version)))
        End Get
    End Property
    Private Shared m_executingAssemblyVersion As
System.Version

    ''' <summary>
    ''' Gets the compile date of the currently
executing assembly.
    ''' </summary>
    ''' <value>The compile
date.</value>
    Public Shared ReadOnly Property CompileDate()
As System.DateTime
        Get
            If Not m_compileDate.HasValue Then
                m_compileDate =
RetrieveLinkerTimestamp(ExecutingAssembly.Location)
            End If
            Return If(m_compileDate, New
System.DateTime())
        End Get
    End Property
    Private Shared m_compileDate As
System.Nullable(Of System.DateTime)

    ''' <summary>
    ''' Retrieves the linker timestamp.
    ''' </summary>
    ''' <param name="filePath">The file
path.</param>
    ''' <returns></returns>
    '''
<remarks>http://www.codinghorror.com/blog/2005/04/determining-build-date-the-hard-way.html</remarks>
    Private Shared Function
RetrieveLinkerTimestamp(filePath As String) As
System.DateTime
        Const  peHeaderOffset As Integer = 60
        Const  linkerTimestampOffset As Integer =
8
        Dim b = New Byte(2047) {}
        Dim s As System.IO.FileStream = Nothing
        Try
            s = New System.IO.FileStream(filePath,
System.IO.FileMode.Open,
System.IO.FileAccess.Read)
            s.Read(b, 0, 2048)
        Finally
            If s IsNot Nothing Then
                s.Close()
            End If
        End Try
        Dim dt = New System.DateTime(1970, 1, 1,
0, 0, 0).AddSeconds(System.BitConverter.ToInt32(b,
System.BitConverter.ToInt32(b, peHeaderOffset) +
linkerTimestampOffset))
        Return
dt.AddHours(System.TimeZone.CurrentTimeZone.GetUtcOffset(dt).Hours)
    End Function
    Private Shared Function InlineAssignHelper(Of
T)(ByRef target As T, value As T) As T
        target = value
        Return value
    End Function
End Class

And use it like this:

Messagebox.Show("This application was
built on: " &
ApplicationInformation.CompileDate.ToString())

NOTE: Grabbed together from http://stackoverflow.com/a/3634544/4237809 and http://blog.codinghorror.com/determining-build-date-the-hard-way/


Categories : Vb.Net

Related to : Setting the value of a constant or variable at build time
Understanding Pointer to constant pointer to integer constant (const int * const * variable)
But i was wondering why is this happening since pcpci is not a constant pointer No, but *(pcpci+1) is. It has type const int* const. Obviously you can't assign anything to that.

Categories : C
Create variable from constant
The variable variable syntax for this case is: define('FOO', 'bar'); $foo = 'baz'; $bar = 42; echo ${FOO}; // 42 Note that this is not necessarily the best approach to i18n, but it answers your direct question. A first step at improving this may simply be to use arrays for starters: $content = [ 'en' => .., 'pl' => .. ]; echo $content[LANG]; The intent and syntax here is much

Categories : PHP
Setting post-build event commands?
You can use MSBuild Post build event to copy the apk from binAndroidDebug to your custom location. You can add PostBuildEvent to project file to execute the copy command or can run task to copy apk from one location to another. <ItemDefinitionGroup> <PostBuildEvent> <Command>copy source_apk_location target_apk_location</Command> <Message>Making a co

Categories : Visual Studio 2013
Setting "Build Active Architectures Only" To "YES" Pros vs Cons?
Yes, I don't think Apple will let you submit the app that way, but if you distribute it in other ways, it won't work on older devices... That's why it's usually set as YES for Debug and NO for Release

Categories : IOS
access parent page constant variable from user control page
Yes you can, if your constant is public. <NameOfThePageClass>.<YourConstantName> Constant variables behave like static variables, with the exception that you can't change them. Since your asp.Net page is a class after all, you can access your constant as you would access it if it was in a standard class. Example: public class MyWebPage { public const string myConst = "test";

Categories : C#
Recently Add
Streamwriter FilleSystem TextFile vb.net
How to add multiple rows
Backgroundworker doesn't move files to correct directories vb.net
XAML child window subclass: "InitializeComponent shadows member in base class." How can I resolve this warning without modifying autogenerated code?
Create and remove controls dynamically
Visual Basic Text Box Array for random number generator - For Homework
How to catch cellmouseclicks in dynamically created datagridviews on TabPages
How to Avoid RunTime Error in List(Of Enum(asByte)).AddRange(List(of Byte))
Using Dynamic Linq to set column name
Set Crystal Reports Jet database password programmatically
resize control.size width designer in vb.net winform ,but this action affected other control size
Overflow Exceptions was unhandled
Read String From Serial port Visual Basic
How to high light rows in list control in vb.net
How Can i know if a string is on MD5 format
activate windows application always
Select item from drop down list using text
Paste text into vb label on formload
vb.net combobox hide item
Deleting record from query table composed of other table's columns(?)
Multithreading - Waiting for threads
Vb.net checkbox won't load from text file
Calculating the value with currency symbols
VB.NET Make Windows shortcuts to different forms in VB.NET program
Visual Basic 2008, Random sting generator with custom length, how to make it?
LINQ - SELECT certain columns
linq any function vb.net
Why am i not receiving serial data in visual studios but i am in putty?
Search a listbox, results will not highlight when searching results found
NullReferenceException using StreamReader in vb
© Copyright 2017 spot7.org Publishing Limited. All rights reserved.