My solution has two exe apps inside. Console application (Console.exe) and wpf application (MyUI.exe). Wpf application is a startup project, and console one is a small installation tool. Both have app.config file which contains db info. I have problem with this config file after I build the solution. In bin folder I have my wpf app and config file with the same name, e.g.:
MyUI.exe and MyUI.exe.config.
But there is no config file for console application. Is there any setting I should set to make it right?
When I set build action to content and copy to output... to Copy always then I have "App.config" file in bin directory, but there is no "Console.exe.config".
There is no such thing as a solution output folder - each project has it's own output folder, in which the App.config will be placed (after it's renamed to [exe_name].config).
Related
I have this WinForms application that uses an external dll file (Winppla.dll) so I can print tags in my Argox printer. Since I cannot add the dll file as a reference to the project, I use the command [DllImport("Winppla.dll")] on my class.
When I run the project in Visual Studio, it works perfectly.
Then I published my application using ClickOnce and when I try to run the application, I get the message error saying that the Winppla.dll could not be found, even though I am running it on my machine.
I tried to:
copy the file to the bin folder of the project before publishing
copy the file to the packages folder of the application before publishing
copy the file to the latest version folder on the Application Files folder (on the publishing location of the application)
add the file as a resource on the project
add a folder with the file as a Reference Path on the project
but none of these worked.
This project also uses SAP CrystalReports, and it works just fine.
Any ideas about how to make it work?
Following #Bearcat9425 instructions in the comments section of the question, I finally solved the problem:
Copy the file to the project folder and include it on the project
(on Solution Explorer, click on 'Show All Files', then right-click in the file and select 'Include In Project')
Mark the file as one of the application files on my publish tab
(right-click on my project and select 'Properties', then go to Publish tab and click on 'Application Files' and make sure the Winppla.dll is marked as 'Include')
Copy the Winppla.dll file to a shared folder in our server (I placed it on the same folder where I placed the setup of my application)
On each DllImport command write the complete path to the file shared location: [DllImport(#"\\the-path-on-the-server\Winppla.dll")]
Publish!
When I build a windows application. It does not work because it cannot read my app.config file. I looked in the bin directory and it does not have the appname.exe.config file. If I manually copy over the app.config and rename it the appname.exe.config the application will work..but when I build the project this file is never created automagically. What am I missing? Why is my project not creating it? I have looked through the whole folder structure and there is no other config files.
Everyone here is giving you false information I think. I think #bowlturner had it right. According to Microsoft, you do need to set the app.config's Copy to output directory property to either Copy Always or Copy if newer. From Microsoft's MSDN Site:
When you develop in Visual Studio, place the source configuration file for your app in the project directory and set its Copy To Output Directory property to Copy always or Copy if newer. The name of the configuration file is the name of the app with a .config extension. For example, an app called myApp.exe should have a source configuration file called myApp.exe.config.
Visual Studio automatically copies the source configuration file to the directory where the compiled assembly is placed to create the output configuration file, which is deployed with the app.
The correct settings are:
Build Action = None
Copy to Output Directory = Do not copy
and very important, the project file needs to contain this element:
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
The only thing that worked for me was to delete bin\ and obj\ entirely. Rebuild and the file is created fine.
Look on App.config properties, should be:
BuildAction: None
CopyToOutputDirectory: Do not copy
Custom tool and custom tool namespace should be empty
Also try to Rebuild project. Right click on project -> Rebuild
Assuming you're using Visual Studio click your config file in the Solution Explorer and and in the Properties panel set Copy To Output Directory to something other than Do Not Copy.
I´m deploying a project in c# windows forms project, that have a file in bin\Release folder that is needed to run correctly the app(it has some configurations to the use of a dll). when i run the app everything is ok. but if I try to deploy using visual studio, and add the file to the Apllication Folder, doens´t work. (no error messages, it happens exactilly the same if take that file from the bin\Release folder)
How can I deploy the project correctlly ?
config files for DLLs are not used in deployed applications. If you need to tweak the configuration of your dll, copy the corresponding sections to the exe config file.
Only the main assembly configuration is taken.
First, you will need to include the file in your solution.
Then, you need to set the Copy To Output Folder property to "Copy Always" or "Copy if Newer".
I have a C# project and an App.Config file in this project. When i build the source code, a file (AssemblyName.exe.config) is created in the output directory for the application configuration but i want the name of this file App.Config. How can i do that?
but i want the name of this file App.Config.
You can use a post-build event to rename the file.
However, realize that the application settings architecture which uses the file will expect the name to be AssemblyName.exe.config. If you rename the file, the normal application settings architecture will break.
You access in your Application Build, in Event Post Build add action who rename file.
rename "YourPath/AssemblyName.exe.config" "YourPath/App.Config"
The nlog.config is being put into the bin/Debug for my project. In the setup project I have primary output of project a and content files of project a to be included in the Application folder. nlog.config, however is not making to the msi. Any ideas?
Adding the file manually means that you will have to redo the step if you change the file in the source.
Instead, make sure that the build action of your NLog.Config is set to "Content"
Then, add Project Output Group of type "Content Files" in your setup project:
.
I have found a solution to this. Right click on the setup project and choose Add then File. Just select the nlog.config file from the bin directory where it is being placed after a compile and it works perfectly.