简体   繁体   中英

Deploying NLog with a ClickOnce application

Users are not able to install a ClickOnce application. The error is: "File NLog.dll is not a valid Portable Executable (PE) file." It works fine on my machine, but I have nLog installed. That's not possible for client machines. Any ideas how to get this to work?

I found the answer to this issue when your NLog.config would not be copied to your program if installed using ClickOnce .

You need to select the NLog.config file in your Project using Solution Explorer and set its Properties as follows:

  • Build Action : Content
  • Copy to Output Directory : Copy always

Now when you deploy using ClickOnce the files should be copied over as well! :)

I put all the NLog config data into the App.config file instead of the NLog.config file and it worked for me after deploying with ClickOnce as well. No errors and the logging was working on the deployed application.

检查您的构建选项,并确保NLog.dll包含在“应用程序文件”中,以便它将处于“下载组”/必需。

If your NLog assemblies are deployed to the GAC then you can't (simply) include that in a ClickOnce setup. Try to deploy them as local DLLs. If that is not possible you will need a separate Setup (or MSI) to deploy NLog.

Add the dll to your project and set BuildAction = None, and "copy to output directory" as "do not copy".

Delete your reference to NLog in your project. Re-add the reference and point it to the dll you just added to the project. On the properties of the reference, set "Copy local" to "true".

Now when YOU run the application, it will point to the local version, and when you deploy the application, it will deploy the local version and point to it.

This works for many 3rd party DLL's, but not all. The best thing to do is to try it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM