Create two (slightly) different executables from same visual c# project - c#

I have a visual c# project from which I want to compile two executables: Full.exe, and Limited.exe. Limited.exe simply hides a couple of UI controls.
I'm thinking of adding another pair of solution configuration (DebugLimited and ReleaseLimited) which simply sets a flag, and then in my build script just build my app with Release configuration and with ReleaseLimited configuration.
Is there an easier way to accomplish this?

If you really want 2 differnet executables this approach works. Make sure that each flavor builds into its own directory. "Build-> batch build" option will let you build all of them at once.
If goal is to have different UI instead of different executables you can use setting in .config file to control what UI to show/hide (with appropritate code to turn on/off controls).

I would make a couple of projects. One called Full and the other called Limited. They are simply wrappers around your main project and set your appropriate options before starting. This way, on a full build of your solution you always get both executables.

Related

Multiple windows withing C# project

I want my project to have two executable windows. Whether that results in two executable files, or if both windows are launched when the exe is double clicked doesn't matter.
I want to be able to close the first window and have the second window continue to run. opening up a new instance of the first window shouldn't effect the second window, and no more than 1 instance of the second window should be allowed to run at once.
Ideally I would like my project to have two executable files, but I'm not sure how to implement this. I don't want to make them separate projects, because they share a lot of the same methods and variables, as well as user settings, but I may have to if that's the only way.
What is the best way to go about this?
Becuase they share so much I would suggest making 3 projects
1 for each of the windows
1 for the shared functionality.
This way, the shared functionality can be compiled into a separate DLL and can be used by both exe's

Custom icon that opens URL

I've only used Visual Studio a handful of times.
Can I make an executable with a custom icon that strictly opens a URL in a web browser?
I am assuming Visual Studio will be the best tool to help me achieve this, although I am open to better options.
It has to have a custom icon and be a stand alone file.
Thanks.
if you don't need it to be an executable you could quickly create a windows shortcut.
http://support.microsoft.com/kb/140443
You can personalize the icon too.
As PrashantGupta has pointed out you can only use a subsets of windows icons if you want it to be a single file.
Sure,
Just write a single line console app with this as your code
System.Diagnostics.Process.Start("http://my.url.com");
You can configure an icon from within visual studio easily too.
Sure, did I get this right: You need an EXE with custom icon and launches a URL?
If you choose C# as your development language the following code will achieve what you want:
namespace URLLauncher
{
class Program
{
static void Main(string[] args)
{
System.Diagnostics.Process.Start("http://www.google.com/");
}
}
}
Changing the icon is also quite straightforward in visual studio as well. See this: Adding an icon to my finished application
Also try not to make your application a "Console" application as that will pop up a "black console window" when you launch the app if you need a double-click interface from the user (which I infer from your wanting an ICON).
Hope this helps.
If you decide to go the C++ route, passing a URL to the ShellExecute function will let you launch a website using the user's preferred browser.
See http://support.microsoft.com/kb/224816
And you don't really need anything from the C or C++ runtime for this, so compile with /NODEFAULTLIB use the /ENTRYPOINT linker option to skip all that, make your executable truly tiny, and have very few dependencies (meaning none that aren't included in every version of Windows since 95). It'll start faster too, not needing to run .NET or any library initialization code.
Add your icon in the usual way using the Resource Compiler.
Solves the problem, not necessarily with the requested tool
While we are at-it, so to speak, I thought someone must have invented this wheel before, so if you are not interested in any development what-so-ever (check licenses before use tho), here are some online tools to do what you want:
Web shortcut producer
Remember to scan the EXE for for malware. Hope it helps :-)
The Visual Studio route has a lot of advantages and will work for this situation. Although, it is overkill for the project I am working on.
I have chosen to go with this solution:
Build a .bat file with the command:
start http://www.google.com
Then use a bat to exe converter which allows icon assignment.
Worked like a charm and quick.

Should I incorporate a setup wizard at first run, or use an MSI?

My program has a handful of settings that need to be established before it can operate correctly. I would like the user to be shown a setup wizard either at first run or at install that has them set everything up to their needs. Right now my program does not use an installer, it just runs from its exe file. The program does offer the option to change these settings when it is running, however I want the user to set the settings first before the program runs. My options seem to be:
Use a setup wizard (either my own or one created such as this link.)
Make the program use an MSI and install. Several have pointed out that an MSI will allow for a program set up while installing which would satisfy the need I have.
As an MSI option sounds like it is the norm for programs I should perhaps learn about those. But I am still curious for other peoples input on this particular problem. For those who are going to recommend the MSI solution, I'm new to this particular aspect of programming, any recommended links are greatly appreciated.
I think it really depends on what your application deployment does. If it simply copies some files and registry entries an MSI will handle most of your needs, including upgrades. Here is a similar discussion which may help you: What is the best SIMPLE replacement for VS Setup-project Installer for WinXP + WPF + .NET 4.0?
If your deployment process involves custom and/or complex tasks, a customized wizard is better because it gives you more control. MSI packages are very limited when it comes to customization.
We do something similar:
Whenever the application is launched, we check the settings storage (usually a database) and if anything needs to be set, we launch the setup wizard.
If the user cancels the setup for some reason, the application is terminated, meaning that the user can't proceed to the main application until the initial configuration is complete.
Having spent an inordinate amount of time configuring (or attempting to configure) installers (Installshield, Installaware, etc), I can promise you that this is the most effective, efficient way to accomplish your goal.
There are some things that you should (and in some cases, have) to do in the installers, but from your description, they don't apply to your situation.

I make changes to a form in design mode but when the program is built the changes are not there?

I am designing a basic app with multiple forms I seem to be coming across this problem and it will probably be something stupid.
When I make a change to my main form in design mode (like add a button), the button appears in design mode and I can code it but when I build the program it doesn't show up.
Any ideas?
Clean and Rebuild
Make sure you're you're starting a correct form in Application.Run in Program.cs
Most Important of all ..
Save your changes !
And make sure that the build compiles (it might not compile and not ask you if you want it to run the last successful build).
Check out what Microsoft themselves say:
http://vidmar.net/weblog/archive/2005/02/04/999.aspx
The problem was resolved. Just go to taskbar> build >clean rebuild.
Some questions:
If you change the code-behind, does the debugger stop on a breakpoint you put on that change? Also, declare a dummy variable and check if it is visible through the debugger windows such as "Locals", "Autos", "Watch" or "Immediate"?
Did you tamper with Form's default constructor (add parameters, change visibility, that sort of things)?
The form you are changing - are you positive that it is actually a main form (check the Program.Main)?
Does your form include user controls?
Did you try restarting the Visual Studio?
Did you try a full rebuild?
Did you try manually deleting all bin/obj folders then rebuilding?
Is your project actually selected for building under current configuration/platform (investigate the Build check-box under Configuration Manager)?
Did the project successfully build (check the error log)?
Are you running the same configuration/platform that you are building? Are you running the same project that you are building?
Ensure the right project is bold in the Solution Manager or check the start-up project in Solution Manager.
Do you happen to use "Start external program" under debugging options?
OK, this is not exactly an "answer", but answering these questions may produce some clues as to where is the actual problem...

Edit and Continue in Silverlight?

Edit-And-Continue is one of my favorite debugging tools which I have previously used on C# based Winforms and ASP.NET projects. However, I'm running a Silverlight 3.0 application on VS 2008 and whenever I try to make a change (after breaking) it says "Changes are not allowed when debugging Silverlight applications". Also there isn't an "Enable Edit and Continue" option in the project settings.
Does anyone (possibly an insider) know when this feature will be supported by Microsoft???
(I NEED IT!)
I doubt it will ever be a feature, to be honest. EAC has always required you to attach directly to your .exe in order to work. In the case of Silverlight, that .exe is the browser, which is not the .exe you are developing.
If you are looking to edit XAML while running, you might consider a dynamic loading situation where you can refresh the control at runtime. In that case, you can edit XAML while debugging, but I'm afraid you're stuck with the managed code.
EDIT:
One possibility that you might consider (but I haven't tried it) is to write your code against unit tests. Then, there is a tool called TestDriven.net that allows you to debug your tests with EAC (as an advanced feature). From there, you might be able to do some EAC, but you will be doing it via unit tests, not actually in the Silverlight environment.

Categories

Resources