Click here to Skip to main content
15,792,217 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Is there a way, at design time to add a text file to my.resources with code. It will only be read when the exe is run by the client. I know how to add to my.resources through the normal way but need to add it with code because the text file will change depending on the user of the exe. For that matter, I can use my.settings if there is a way to add a setting with code at design time

What I have tried:

Have not really tried anything because I know of no way to accomplish this.
Updated 26-Sep-22 19:54pm
Member 15627495 26-Sep-22 23:00pm    
read somtimes the help from Microsoft when you need it.
select the keywords , and press F1.

My.Resources seems to be 'read only'.
and only reachable by VStudio menu 'project settings/resources'
It's files added before compiling your projects.
Gary Corbell 2021 27-Sep-22 0:06am    
Thanks for taking time to respond. I really appreciate any input. Have a good one.

That's a pretty bad idea: it causes configuration problems that can quickly spiral out of control because you need effectively a different EXE file for each client, and there is no obvious way to work out which EXE is which without effectively disassembling it.

I assume this is so that you can add some kind of licencing so the EXE will run only on a specific machine? Even then, it's a fairly bad idea as upgrades need exactly the right file added to them each time for as many clients as you have.

Instead, use an external file located in a common folder (this may help: Where should I store my data?[^]) and create the licence file as part of your installation process (by "phoning home" to convert a machine ID into a licence file).
Share this answer
Gary Corbell 2021 27-Sep-22 9:47am    
Thanks for responding.
OriginalGriff 27-Sep-22 10:05am    
You're welcome!
I don't think you're going to be able to execute any code in your project during the compile to do this.

AFAIK, you would have to write an MSBuild extension (called a Task) to do it, then manually add this Task to your VB project file (.vbproj) in an appropriate place.

You're going to have to read up on MSBuild and Tasks[^].

Your Task is probably going to have to do it's work in your Resources.resx file, then run a tool called ResGen to generate the Resources.Designer.vb code.

I say "probably" because I honestly don't know how to do it. All I've done is drop the files found in the My Project fold into Notepad and poked around a little bit.
Share this answer
Gary Corbell 2021 27-Sep-22 9:47am    
Thanks Dave. Appreciate the response.

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