Manifest files and VS.NET

I created a manifest file to enable Windows XP themes in my app.  It works if I manually copy the manifest file into the same directory as my EXE.   However, I don't want to have to manually copy the manifest file into the EXE's directory.  Instead, I want the manifest file to reside in the same directory as my source code, and then at compilation time, have VS.NET copy this file into the EXE's directory.  Is this even possible or is what I am asking for beyond the capabilities of VS.NET   I'm using VS.NET 2002.

Answer this question

Manifest files and VS.NET

  • tenlbham

    Just in case anyone is reading this thread and has the same question I had, here's the answer I came up with.  After doing some more research on the topic, this feature is beyond the capabilities of VS.NET.
  • Anton Eagle

    Nice code Josh...  It works nice...  Thanks for the help.

    Rubén Quiñones

  • gknierim

    If the manifest file is parent of the build process and set up as a loose file it will get copied.  If you have a setup program, you can also include it to copy.  I do this with images all the time, and I never have an issue with them getting copied to the appropriate location.

    Note, the manifest creation code written by Josh is also kind of cool in case the user deletes your manifest file.  But it won't run if your program operates without Administrator or Power User privelages and it installed into the Program Files directory.  This is actually a common scenario in a work environment with a release application.  Under these circumstances, the manifest file needs to be copied in the installation program when an administrator is doing the install.

  • iyajimi

    I disagree here is a VB version of doing just that.

    here is a function to place in a class somewhere or on you main form. Just make sure you call it after the InitializeComponents is called 
    i.e. MainForm
            'This call is required by the Windows Form Designer.
            InitializeComponent()
            App.SupportXP()

    here it is.


        Public Function SupportXP()
            ' XP Theme Support

            Dim x As String
            Dim y As Integer
            Dim AppName As String
            Dim ManFileName As String
            Dim AlreadyExists As String
            'Find the name of this application
            x = Application.ExecutablePath
            y = x.LastIndexOf("\")
            y = y + 1
            AppName = x.Substring(y, x.Length - y)
            'Create the name for the manifest file
            ManFileName = AppName & ".manifest"
            'See if the manifest exists
            If System.IO.File.Exists(ManFileName) Then
                AlreadyExists = "Y"
            Else
                FileOpen(1, ManFileName, OpenMode.Binary)
                FilePut(1, "< xml version='1.0' encoding='UTF-8' standalone='yes' >" & vbCrLf)
                FilePut(1, "<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>" & vbCrLf)
                FilePut(1, "<assemblyIdentity version='1.0.0.0' processorArchitecture='X86' name='AccessTracker.exe' type='win32' />" & vbCrLf)
                FilePut(1, "<description>NET Access Tracking Program</description>" & vbCrLf)
                FilePut(1, "<dependency>" & vbCrLf)
                FilePut(1, "<dependentAssembly>" & vbCrLf)
                FilePut(1, "<assemblyIdentity type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='X86' publicKeyToken='6595b64144ccf1df' language='*' />" & vbCrLf)
                FilePut(1, "</dependentAssembly>" & vbCrLf)
                FilePut(1, "</dependency>" & vbCrLf)
                FilePut(1, "</assembly>" & vbCrLf)
                FileClose(1)
                'Open a new instance of the app and close this one
                'so the manifest is picked up
                Shell(AppName, AppWinStyle.NormalFocus)
                End
            End If
        End Function

    :)
    Josh Crosby, hope this will help you.

  • Razbir

    Hi Justin,

    What do you mean by 'set up as a loose file'   Can you provide a few more details on how to get this to work   

  • Manifest files and VS.NET