Deploying NLog Using a ClickOnce Application
Users cannot install the ClickOnce application. Error: "The NLog.dll file is not a valid Portable Executable (PE) file." It works fine on my machine, but I have nLog installed. This is not possible for client machines. Any ideas how to get this to work?
I found the answer to this question when yours NLog.config
will not be copied into your program if installed with ClickOnce
.
You need to select the NLog.config
file in Project
with Solution Explorer
and install it Properties
like this:
- Build action . Content
- Copy to output directory : always copy
Now when deployed using ClickOnce
files should be copied too! :)
I put all the NLog config data in the App.config file instead of the NLog.config file and it worked for me after deploying with ClickOnce. The deployed application had no errors and no logging.
Check your build variant and make sure NLog.dll is included in the Application Files so it is in the download group / required.
If your NLog assemblies are deployed to the GAC, you cannot (simply) include this in your ClickOnce setup. Try deploying them as local DLLs. If this is not possible, you will need a separate installer (or MSI) to deploy NLog.
Add the dll to your project and set BuildAction = None and "copy to output directory" as "don't copy".
Remove the reference to NLog in your project. Re-add the reference and point it to the DLL added to the project. Set Copy Local to true in the link properties.
Now when you run the application it will point to the local version and when deploying the application it will deploy the local version and point to it.
This works for many third party DLLs, but not all. Your best bet is to try this.