Click here to Skip to main content
15,885,196 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello everybody, hope I don't wrong anything.
I'm trying to create a program in VB.NET and I'm going crazy, so if anyone could help me he would make a great favor!

Here's the question : I have two form on my project;

In form1 there is two button and one textbox, in form2 there is just one label.

I want that after I insert a name on the textbox on form1, by pressing the first button the name inserted goes copied into the label on the form2 (and I did this ;) ) and by pressing the second button it appear a savefiledialog that allow me to save an .exe file of my form2 (with the label changed text i chose before).

So, how can I save a form into .exe depending on the modified value I insterted before?

I tried by copying the source of form2 and form2.designer.vb into a .txt file in My.Resources and after I tried to compile it with the CodeDom Compiler but it doesn't work, it appears so many errors and seems it cannot compile vb.net strings (?)

So I don't know if there is any methods to do this.

Maybe is easy but I'm really getting crazy.

Hope someone could help me, any idea or any tips, don't hesitate to ask if you didn't understand everything, I'll try to explain better.

Thanks to anybody and sorry my bad english.
Posted
Updated 26-Jun-14 6:15am
v3
Comments
[no name] 26-Jun-14 12:33pm    
Why are you doing this at all? This smells of a bad application design to me.
CHill60 26-Jun-14 12:50pm    
Are you sure you want to "save" as a .exe? Most people would compile to create an exe.
And we can't help you with the errors unless you tell us what they are... and share your code
Sergey Alexandrovich Kryukov 26-Jun-14 14:11pm    
It does not seem to make any sense. CodeDOM always creates and executable on successful build, even if you target the assembly loaded in memory — CodeDOM simply creates the file(s) (and you can get a file name) and then loads and assembly from it. Your manipulations with source file look irrelevant. Practically, you never have to copy anything; you simply give CodeDOM the file names. You either successfully build from CodeDom or not.
—SA

This is alternative approach:
how about creating exe which load configuration data from file? for example you can load the label text from text file and set it when form load. You only need to change the text file by other application.
 
Share this answer
 
Comments
Member 8078971 27-Jun-14 15:10pm    
Thanks you for your solution, seems the best for now, I succesfully implemented an .XLM config file and work fine but this solve only partially my problem : I need to save data into the program so, after the program load the data from the .XLM config file, the data should be recorded by the program itself.
I used My.Settings namespace but this save the data from the .XLM file to another .XLM configuration file located in my AppData folder.
So, if I send my program to another computer without config.xlm file it won't work.
And I need , after save the data from my .XLM file (just so the user could interact with my program) to save in the program itself so the user could access his data from another computer without move .xlm configuration file (it's unconfortable).
Can you help me , or should I make another question ?
Hope I was clear, anyway your way helped me alot, thanks.
No, you cannot "save a form as an .exe". It's simply not possible.

You have to use the CodeDOM to build an entire application and then add your text that you sent to a label as a string constant into this app code. You then use CodeDOM to compile that code into it's own .EXE.

Warning! It is a SH*T-TON of work to do this! You'd be better off with the answer in Solution 1. Just write the text to a config file that your second app just loads.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900