Can't copy XML on Clickonce deployment - c#

I have a solution with 2 projects:
MainSolution
Project A
Project B
Folder A
Settings.xml (Embedded R.->Copy Always)
But when I try to deploy it over ClickOnce, I got an error when the app starts, something like: "Could not find the .xml file", so the problem is basically that in the deployment part the file is not copied over the output directory.
I tried to:
*Change the output dir from my project B to the bin\debug in project A
*I included my project B as required in the app files for project A in the publish setting of my main project (Project A).
PS: The error is obtained when I tried to retrieve my settings in the fiel, I tried to use:
*Application.StartupPath + "\Folder\Settings.xml
*Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.FullName) + "\Project B\Folder\Settings.xml"
Thanks, regards.

There is no "Project B" folder. When the application is deployed, everything would be in the "Project A' folder. Also, you have indicated that "settings.xml" file is an "Embedded Resource". Therefore that resource will be available via Assembly.GetManifestResourceStream Method.

Related

Publish a file from an included project to App_Data

I have an mvc project (A) and this has a reference to another project (B) which includes a specific dll. I need this dll to be published to the app_data folder of any project which references project B.
I have tried setting it's build action, and the copy to output directory, but this doesn't seem to help. I've made sure the app_data folder exists on the server, and can publish files which are directly in the app_data folder of project A.
i have met this problem. I solve like that; move manually app_data files in publish folder. If App_Data folder exist in publish folder copy and paste from project to publish folder. If not exist create manullay.
Keep the "copy to output directory" but note that will only put the dll in the bin output folder. However, from there you can copy it to App_data after the build: in the project properties, select the Build Events tab and add this to the post-build events (updating for your dll):
xcopy "$(ProjectDir)$(OutDir)your.dll" "$(ProjectDir)App_Data\" /Y

How to copy a file to application folder in set up project during insatllation. File is in set up folder

I have a xml file in the setup folder of a windows application. Now during the installation how do i copy this file to my application's folder so that it can be copied to this path C:\Program Files (x86).......
I can not add the file to the application folder in the setup project because the content of file might change after build of setup project.
Its an external xml file in located inside set up folder. and I want to copy this file on installation path(C:/Program Files...) during installation. I will give this file with msi installer in side installer folder.
Please provide any idea if someone have....
If I'm understanding you correctly, this might solve your problem, or at least get you started:
Include the file in the main project (for instance in a folder called "resources"). Right click the file in VS, choose properties, and set Copy to output directory to Coppy Always.

Configuration File in C# default location?

I have just created a WPF application and just been wondering where is my app.config file?
I looked in the bin/Debug and bin/Release directories and there is just one file "WpfApplication1.vshost.exe" and could not find any app.config file.
All I can do is Add->New Configuratin File and this too, doesn't come in debug or Release folder.
Can anyone guide me whether I should manually copy and paste it in the debug or Release Folder?
So finally: the ANSWER
If app.config does not exist, then try creating a new one by "Add->New Item->Application Configuration File" and create a file named "App.config". After this, try rebuilding your application, the .config file specific to your project should appear in bin/Debug & bin/Release folder.
It should be getting copied into the Debug/Release folders automatically. However, you could try explicitly setting the "Copy to output directory" in the properties to Copy always and see if it appears.
After creating simple WPF project my solution look like this. App.config lies there, which is the configuration file itself
When you build your solution, which in my case is named as WpfApplication1, config file lies at WpfApplication1.exe.config in \WpfApplication1\bin\Debug\ folder.
When you build your application,it automatically gets copies to debug/Release Folder.just look for *.config file in those folders.
If you build your project you should have a file named foo.bar.exe.config in you binary directory. The app.config file itself should be visible within your solution directory.

Publish dll - copy to bin folder

MVC project.
On my data access layer I have a libs folder where I store some dlls that the project needs t oaccess data. One of them is set "copy local" to true. The goal is to copy the dll to the bin folder so I can deploy it with the application.
The thing is, when I build the app, it does copy to the bin folder, but to the bin folder on the DAL project only. Since it is a web applicaiton I want to build the web project and have the dll copied to its bin folder so I can just deploy it withou having to manually coping it from the bin on the dal to the bin of the deployed appliation.
What do I need to do to accomplish that?
Build Action = Content might help; but then it will only come in to your DAL Bin if it is referenced there.
You can right click on the web project and than click on Deployment project as given below ..this will add all required dll for your project in the path of your poject which you can see in ouput window

c# winapp add app.config to installer?

Okay I've got my app.config file that is containing my database settings.
All works well on my development machine. But when I install it on a test machine I'm getting a null reference on the following line:
ConnectionString = ConfigurationManager.ConnectionStrings["MyDBConn"].ToString();
Why is this happening? I guess that the app.config file isn't found. But isn't this included when you build the setup?
I'm using a very simple setup project in VS2008.
The file app.Config is your source, don't distribute it. When Visual Studio builds your project it copies the file to {AppName}.exe.config (in the same folder as {AppName}.exe ) and that is the file you need to include in your setup.
Select app.config in solution explorer and in the properties tab choose the copy action:
Copy to Output Directory -> Copy always
or
Copy to Output Directory -> Copy if newer
Remember to rename the app.config to the name of the exe.
ie.
myprogram.exe would have an app.config called myprogram.exe.config

Categories