19

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?

4 Answers 4

19

I fixed the same issue by downloading the schema from "http://www.nlog-project.org/schemas/NLog.xsd" then saving it to my project directory and adding it to the project ...

  • Right click project name in solution explorer.
  • Select Add | Existing item
  • Browse to the new xsd file and select it.

Then the warnings went away.

Sign up to request clarification or add additional context in comments.

2 Comments

Just to add. I had similar issue and it was looking for at a specific folder "C:\Users\myusername\.nuget\packages\nlog.config\4.5.6\contentFiles\any\any" I followed steps above to download file and added to the location I just listed and it worked properly
I just ran into this issue, and this fix worked. I also wanted to add that if you are downloading the file as a ".xml" it will fail change the extension to ".xsd" and you may need to add the file manually by navigating to the file path in the warning message.
14

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.

1 Comment

That's a great find! One must be careful when using uncommon characters in file paths. I try to never even use spaces in file names of paths.
13

This worked for me in visual studio.

  • Go to Project -> Manage NuGet Packages -> Browse for NLog.Schema
  • Install it

2 Comments

NuGet copies the file to <UserDir>\.nuget\packages\nlog.schema\4.7.14\contentFiles\any\any While VS looks for it in <UserDir>\source\repos\<SolutionName>\<ProjectName>
For me, the file was installed correctly at project level.
0

You can directly reference the latest schema by giving the full url:

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

This will work for project reference styled projects.

But it will expose you to another problem with custom targets. (NLog xsi:type not working with custom target)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.