Changing the config file in a Visual Studio Package - app-config

I'm building a Visual Studio Package and associated with it, I have an app.config file (which contains some information about connecting to a WCF service).
As far as I can tell, this package is actually connecting to the devnev.exe.config configuration file (if I use AppDomain.CurrentDomain.SetupInformation.ConfigurationFile), it will retrieve the path to the devnev.exe.config
Firstly, is this correct? Shouldn't the package automatically pick up the app.config file? If this is the case, then how can I make the project use the app.config file?
I'm running VS2010 Ultimate, programming in C#.

A Visual Studio Package will take the devnev.exe.config configuration file as its main configuration file. If you add an app.config file into the project, it will not accept it. This is because the package is running within Visual Studio, therefore it is accepting Visual Studio's config file.
At the same time it is not good practice to change the devnev.exe.config file, since once you deploy your application, the user will also have to change that file (and on the whole, you shouldn't change that file).
What I ended up doing is connecting to the WCF service programmatically.
Hope this helps somebody.

When you compile your project the app.config is compiled as [exe].config.
If you want to change configuration you can change the content of [exe].config (it's a plain text document).

Related

I am getting "myApp stopped working" after installig my WPF(+telerik) application

I created a WPF application using telerik control suite (WPF telerik controls and ORM access control) and SQL Express R2 2008 in VS 2012.
Then I created its setup files (using install shield LE and also Advanced Installer) which works on my win7 system, properly () .but when I install the setup file on any other win7 system, it doesn’t work( I am getting this error: “MyAPP has stopped working”).
I installed .NET framework and SQL Express R2 2008(the service’s status is running) and I also copied the mdf and ldf files related to the database in right path that specified in app.xaml.
When I install my setup files, it just copy my project’s debug folder (contains the telerik control dll files, the dll file related to my ORM access control project, built exe file and etc.). I think that’s enough. Isn’t it?
Edit:
The project's Solution's Explorer:
\bin\Debug
I have no idea what to do.
I would really really appreciate any hint or comment.
Regards,
Hiva
I know this is a very general answer although without knowing the details of your project it's the best I can do. I remember when I was creating an app using telerik controls, when I went to publish it I was getting errors in the with the assembly which was a result of including the obj / Debug / Release folders in my project. I tried everything that people listed to get rid of the errors but the only thing that helped was creating a new project, copying in the code and NEVER including(Never right clicking and hitting include in project) those folders in my project.
Is it working when you debug it?
Could you please let me know what steps you are taking to publish the app ?

.NET Reactor and InnoSetup

I have a VS 2010 C# "solution"; It creates an .exe file, and a .pdb file when doing a build in Release mode which I use in the InnoSetup build of the installer.
My app uses several .dll's from other vendors (i.e. WinSCP). My question is: do still build the installer using InnoSetup, substituting the new .exe from .NET Reactor for the one created by Visual Studio? The only thing I want to obfuscate using .NET Reactor is my app, not the other vendors.
(I have looked in Google and SO, and did not find an answer.)
You could directly substitute the exe/dll before you build the installer.
In case you want to automatically protect a VS project file output (exe/dll) before it is packaged into your into you setup you could use the .NET Reactor Visual Studio Add-in.
Install dotFuscator then you will be able to add its project type in source code as new project. There you can set output files to obfuscate.

Set app.config parameters from a Visual Studio 2008 Setup project

I have a WinForms application that uses a config file to specify where it's external files will be created.
Is it possible to use the installer to question the user where the files should be located and add this value to the config file?
It would also be good if I could confirm that the user has entered a valid path but that's just a "Nice-to-have" at the moment.
Following the helpful hints from Pete, I was able to find this blog that does exactly what I need.
There are a few Gotchas to watch out for and I've covered them here but these may be Visual Studio 2008 specific issues.

clickonce file missing

Using Clickonce with VS 2010 and .NET framework Client profile 3.5, I have several file folders with application level XML and/or textfiles that are needed at runtime.
The file folders sits in the same project where they are to be used.
These files are marked as "Copy always" at compile.
Build Action is "Content".
On my development machine the files are actually copied into the ./Bin/Release/myFileFolder/xxxxx and all is fine.
On user's computer, install runs fine but some files are reported missing at runtime when the program need them.
Do I miss something? Is any file specific option deep hidden in the option list?
Help please! and .NET framework 3.5
If the files are in referenced projects then they are not included in the click once publish by Visual Studio. You can verify this by checking the application files dialog in the publish page of the project properties.
Assuming this is the case to get these files included you can either add them as links in the main project itself or edit the project file to include extra files in the manifest. See ClickOnce Content Files for information on how to do this.
I can confirm that this can still be an issue in Visual Studio 2019.
I have been working on DevExpress dashboards that consume XML files at runtime to produce their dashboard layouts, and whenever I would publish my project, I would get a bizarre error about the XML file not being found when clearly it was published to the same output directory as the rest of the project.
Just to be clear, the XML file existed in my Visual Studio project and was set to Build Action = Content and Copy Always To Output Directory.
What I had to do was what was suggested in this answer:
Go to Project Settings.
Open the Application Files list.
Change the Publish Status of the XML file - which Visual Studio automatically set to Data File (Auto) - to Include.
Voila. FileNotFound error magically disappeared after publishing the project.
A workaround is to make your application create the xml/txt files if they dont exist.

Add a assembly to GAC and Add reference dialog in visual studio 2010

HY,
Know someone how can i add a assembly to GAC and Add reference dialog automatically in same time.
I have a setup project which i set him to add the assembly automatically to GAC, but i can`t add that in add reference dialog from visual studio 2010. I search on the internet but i didn't found how to do it.
The idea is that i have a project template from a project which use two assembly. I want to placed the 2 assembly in GAC when he is running the setup of the framework which i give to him.
Thanks.
Your English is hard to decode but it sure sounds like you are on the wrong track with this. The GAC is a deployment detail. You'll have no trouble putting an assembly in the GAC with your Setup project.
That assembly does not belong in the GAC on your dev machine. To add the reference, simply use the Add Reference dialog and use either the Project or Browse tab.
If your assembly is intended to be used by another programmer so that she can use your product in her own project then you need to deploy your assembly twice. It needs to go into the GAC and a copy of the assembly needs to go in a dedicated folder so your client can add the reference to it in her own project. The c:\program files\reference asssemblies directory is a good place to put it.
Putting it in the GAC for her is optional btw, it isn't that commonly done. I think most programmers would prefer that you don't do this, unless you work for a Big Company that needs to automatically distribute security updates. Putting it in the GAC just makes it harder for your client to write her own Setup project since she has to run yours first.
tribanp
I've created a sexy visual studio extension that will help you to achieve your goal. Muse VSReferences will allow you to add a Global Assembly Cache reference to the project from Add GAC Reference menu item.
Regards...
Muse Extensions

Resources