Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# NLog; Cannot find NLog.xsd file

Tags:

c#

nlog

xsd

Just for the case that somebody produces one day the same error.

In the starting section of the NLog.config file Visual Studio tells me (with a warning) that it cannot find the NLog.xsd File

<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd"

That is the reason why I cannot use intellisense while editing the config file. Although NLog is installed with the config section and all files are present in the project folder the error persists. Why?

like image 378
Mong Zhu Avatar asked Mar 02 '16 08:03

Mong Zhu


2 Answers

This worked for me in visual studio.

  • Go to Project -> Manage NuGet Packages -> Browse for NLog.Schema
  • Install it
like image 169
Ankit Giri Avatar answered Sep 23 '22 09:09

Ankit Giri


So, by hovering with the mouse over the blue underlined line of code in the NLog.config file:

xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd"

I realised that Visual Studio was searching for the file 2 folders above my project folder. The solution was that the parent folder of my project folder had a "#" in its name! Thereby apparently preventing VS from finding the config file. After removing the "#" the warning disappeared and I could use intellisense again.

like image 44
Mong Zhu Avatar answered Sep 23 '22 09:09

Mong Zhu