Search code examples
c#xsdnlog

C# NLog; Cannot find NLog.xsd file


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?


Solution

  • 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.