Compile standalone exe in visualbasic express 2010 with resources

Discussion in 'Mixed Languages' started by stevemk14ebr, Dec 10, 2011.

Thread Status:
Not open for further replies.
  1. stevemk14ebr

    stevemk14ebr MDL Senior Member

    Jun 23, 2010
    267
    48
    10
    My problem is i need to compile my exe's as stanalones WITH the resources in that exe or something. When i go into my bin/release to get my exe the exe "stops responding" if i use resources like pictures or sound in that program. I'm wondering if it is possible to compile a true standalone exe of my programs without having to make an installer as they are just fun little games and not really worth installing.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  2. user_hidden

    user_hidden MDL Expert

    Dec 18, 2007
    1,026
    982
    60
    can't remember but it should be something like:

    project > "yourprojectname" Properties
    left pane choose Resources
    add your files
    refference them by the My.Computer.FileSystem
     
  3. stevemk14ebr

    stevemk14ebr MDL Senior Member

    Jun 23, 2010
    267
    48
    10
    no i already have files added,and they run fine in my program on my pc,and on anothere pc if i use an installer,but if i pull the exe out of bin/release the program crashes crashes.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  4. user_hidden

    user_hidden MDL Expert

    Dec 18, 2007
    1,026
    982
    60
    google: BoxedApp Packer
     
  5. stevemk14ebr

    stevemk14ebr MDL Senior Member

    Jun 23, 2010
    267
    48
    10
    sounds like what i need ill report my progress later
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  6. Alphawaves

    Alphawaves Super Moderator/Developer
    Staff Member

    Aug 11, 2008
    5,891
    20,335
    180
    Sounds like your app is relying on your writen files to reside with it ?
    Can you post your code ?
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  7. stevemk14ebr

    stevemk14ebr MDL Senior Member

    Jun 23, 2010
    267
    48
    10
    yes it is using picture files and music files and such in my resources that i've added through visualbasic express. I simply am making the background of a square an image that i have in my resources, or playing a music file,nothing fancy. But when i go to build and build my program it seems like it doesnt include those resources in my program when i get it from the bin/release folder i was wonder how u guys on this forum are able to compile ur apps into a standalone exe yet still have images and stuff in your apps.

    code(in visualbasic):
    door1.Image = My.Resources.door_open_and_close_vector
    door2.Image = My.Resources.door_open_and_close_vector
    door3.Image = My.Resources.door_open_and_close_vector
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  8. Stannieman

    Stannieman MDL Guru

    Sep 4, 2009
    2,232
    1,803
    90
    Aren't you doing something else wrong then? Cause if the files are really in the resources then that can't be the problem.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  9. Alphawaves

    Alphawaves Super Moderator/Developer
    Staff Member

    Aug 11, 2008
    5,891
    20,335
    180
    #9 Alphawaves, Dec 11, 2011
    Last edited: Dec 11, 2011
    I may have totally misunderstood your question, i dont exactly understand what your trying to do so i may be way off..
    The file you added to resources are inside the application, you would need to use File.WriteAllBytes("save file here", My.Resources."your file") for it to be used by your app (you would code your app to detect it)..

    Wouldn't, door1.BackgroundImage = My.Resources.door_open_and_close_vector be better..
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  10. stevemk14ebr

    stevemk14ebr MDL Senior Member

    Jun 23, 2010
    267
    48
    10
    I have my resources in my project file, i just dont know how to get those resources to be compiled into a standalone exe with my resources. My program works fine when debugging and such it just compiling it with resources to use on another pc
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  11. user_hidden

    user_hidden MDL Expert

    Dec 18, 2007
    1,026
    982
    60
    you would need to write your embedded files to a temp area:

    My.Computer.FileSystem.WriteAllBytes(My.Computer.FileSystem.SpecialDirectories.Temp & "\OriginalFileName", _
    My.Resources.FileNameGivenInResources, False)

    than refer to them in your code

    door1.BackgroundImage = My.Computer.FileSystem.SpecialDirectories.Temp & "\OriginalFileName"
     
  12. Alphawaves

    Alphawaves Super Moderator/Developer
    Staff Member

    Aug 11, 2008
    5,891
    20,335
    180
    #12 Alphawaves, Dec 12, 2011
    Last edited by a moderator: Apr 20, 2017
    You would need to use New Bitmap:

    Code:
     door1.BackgroundImage = New Bitmap(My.Computer.FileSystem.SpecialDirectories.Temp & "\OriginalFileName")
    ;)
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  13. user_hidden

    user_hidden MDL Expert

    Dec 18, 2007
    1,026
    982
    60
    you knew what I meant :cool:
     
  14. stevemk14ebr

    stevemk14ebr MDL Senior Member

    Jun 23, 2010
    267
    48
    10
    #14 stevemk14ebr, Dec 12, 2011
    Last edited: Dec 12, 2011
    (OP)
    ok when i try the exact code u posted i get filenamegiveninresources not a membero of resources then when i put the resource name in instead i get an error that system.drawing.bitmap cant be converted to 1 dimensional array of bytes
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  15. stevemk14ebr

    stevemk14ebr MDL Senior Member

    Jun 23, 2010
    267
    48
    10
    ^edited to show my results
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  16. Alphawaves

    Alphawaves Super Moderator/Developer
    Staff Member

    Aug 11, 2008
    5,891
    20,335
    180
    #16 Alphawaves, Dec 13, 2011
    Last edited by a moderator: Apr 20, 2017
    If you added the images with there extentions intact, ie: (wallpaper.jpg).... then you should be ok to use:

    Code:
    PictureBox1.BackgroundImage = My.Resources.wallpaper
    EDIT:

    Im not sure if this will be of any use to you, i tried to make a little example of what i thought you were asking.
    I may be well of again :laie:

    VB.NET Test
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  17. stevemk14ebr

    stevemk14ebr MDL Senior Member

    Jun 23, 2010
    267
    48
    10
    #17 stevemk14ebr, Dec 13, 2011
    Last edited: Dec 13, 2011
    (OP)
    OMG IT WORKED your project did exactly what i want to do, all i have to do now is examine your app and implement that into mine...THANK YOU

    P.S thanks for the time you put into the app
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  18. Alphawaves

    Alphawaves Super Moderator/Developer
    Staff Member

    Aug 11, 2008
    5,891
    20,335
    180
    Cool, no problem, glad to be of help..;)
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  19. stevemk14ebr

    stevemk14ebr MDL Senior Member

    Jun 23, 2010
    267
    48
    10
    #19 stevemk14ebr, Dec 13, 2011
    Last edited: Dec 13, 2011
    (OP)
    ok srry to be such a noob..but i dont see why mine isn't working i'm working with picture files in the resources i refer to them the same way as u (my.resource."insert resource name") but it still doesnt bring up my picture even when i've added it to my resources

    p.s keep in mind this works on my pc but if i take the exe to any other computer it doesnt work, but urs worked on one of my others

    edit: to see if you can find what my problem is here is link http://www.datafilehost.com/download-402440fa.html
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  20. Alphawaves

    Alphawaves Super Moderator/Developer
    Staff Member

    Aug 11, 2008
    5,891
    20,335
    180
    Runs ok on 3 pc's here, do your other pcs have the .Net Framework 4 installed:eek:
    Ill have another look in the morning..;)
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...