PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
VS 2012 [Visual Studio] Compiling only that code that is actually used-VBForums
Results 1 to 3 of 3

Thread: [Visual Studio] Compiling only that code that is actually used

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2009
    Posts
    629

    [Visual Studio] Compiling only that code that is actually used

    I started to finally fix my place up a bit by grouping up commonly used functions into a single namespace so they can be used by many projects at once.

    This question is related to three problems I am having:
    • Final executable size
    • Compatibility of PInvoke methods
    • Security (antivirus triggers)


    Having all this common code means that a large portion of it is not used at all by the final application. However, there is a lot of interconnected calls (for example, from 'Path' to 'File' and 'Window' to 'User32') which means it is not possible to just delete the files not of interest. Since the executable contains so many PInvoke calls for Windows API, pretty much any antivirus will detect this and flag it as a virus, even though none of the code paths lead to these functions. It makes sense that an application with the ability to read text in other applications is a hazard, same for global keyboard hooks.

    There is one solution to this, and it is commonly found when compiling C/C++ code: do not compile functions and classes that are not being used. I've found that the Visual Basic (or .NET compiler in general) is doing a poor job, if any, to exclude code from compiling when it is not being used.

    Is there a way to configure the .NET compiler so it will not include unused functions in the final executable? If not, is there perhaps a tool available that can do it?
    It is not a good idea to distribute programs to friends and then having to proof to them I'm not hijacking their installation after they receive 5 antivirus warnings.

  2. #2
    Still learning kebo's Avatar
    Join Date
    Apr 2004
    Location
    Gardnerville,nv
    Posts
    3,708

    Re: [Visual Studio] Compiling only that code that is actually used

    you can declare compiler directives (I think that's what they are called)

    Something like this even I didn't get the name correct....
    vb Code:
    1. #Const LEAVE_THIS_OUT = True
    2. #If LEAVE_THIS_OUT Then
    3.  
    4.     'this won't compile if LEAVE_THIS_OUT is true
    5.  
    6. #End If
    Is that what you are looking for?
    Last edited by kebo; Jan 25th, 2014 at 09:49 PM.
    Process control doesn't give you good quality, it gives you consistent quality.
    Good quality comes from consistently doing the right things.

    Vague general questions have vague general answers.
    A $100 donation is required for me to help you if you PM me asking for help. Instructions for donating to one of our local charities will be provided.

    ______________________________
    Last edited by kebo : Now. Reason: superfluous typo's

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2009
    Posts
    629

    Re: [Visual Studio] Compiling only that code that is actually used

    @kebo

    Interesting, I did not expect that to be possible in VB .net, I'll keep it in mind for the future, thanks. I'm more looking for an automated method though, one that looks at the startup code of the Form and recursively compiles code as it is used, as opposed to compiling every single file and dumping it all in the executable.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width