18

When I open up an xsd file that includes other xsd files, all of the included files are added to a section called "Unauthorized zone". Visual Studio highlights the xs:include element and gives the following error when trying to resolve the schemaLocation attribute:

Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

I've read the following blog post, but I'm not familiar enough with xsd yet to fully understand it.

Can anyone explain why this is happening or point me to a good resource that can help?

[Edit] All of the xsd files that are to be included are in the Visual Studio project.

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
starskythehutch
  • 3,328
  • 1
  • 25
  • 35

4 Answers4

23

For me it worked after going to the properties of the XSD file and clicking on Unblock. i got this answer from How do I modify my settings to allow VS2010 to load 3rd party XSD files from the "Unauthorized Zone"?

Community
  • 1
  • 1
alsolh
  • 416
  • 4
  • 6
  • That is one obscure thing, and even in VS 2022 it is still a problem - as in: it doesn't show a proper error message, just very confusing tool tips. I only found the problem after seeing VS accessing the "Zone.Identifier" NTFS stream and then remembering that I downloaded the XSDs from the W3C website. – Alexander Gräf Jun 17 '22 at 18:45
  • Had to reload VS 2022 to take changes effect. – M.Buschmann Aug 03 '22 at 09:35
2

Visual Studio caches XSD schemas at %VsInstallDir%\xml\Schemas with Target Namespace attribute (url of schema file) when you add them to your editor.

Blog post says that
The inclusion of Local.xsd in the “Unauthorized Zone” and the warnings in the error pane about not being able to resolve the schema location are an indication to the end user that the schema they were visiting attempted to bring in a schema from a zone that it is not authorized to access.

Reason the IO Permission error shows itself is your machine has no authority to download external xsd file(s) from the location.So there is no cache that Visual Studio might validate your other xsd files.

You should check your networking options so you may download those xsd files.While you can it means you have access to that location,so Visual Studio can cache them.If you're sure that you have access,you may also download those xsd files and put them Visual Studio's default schema location and indeed add them in editor.

Also check about cache here

Hope this helps
Myra

Myra
  • 3,646
  • 3
  • 38
  • 47
  • Thank you for answering. I was under the impression that that folder was for xsd files for consumption by Visual Studio. This line would seem to suggest that: Because the schema cache directory is global to your computer, you should only add schemas here that are standard and useful to all the Visual Studio projects that may be created on your computer. Is this not correct? – starskythehutch May 27 '10 at 13:58
  • Correct,You can add local or external schemas as long as you have xsd files. – Myra May 27 '10 at 14:39
  • 1
    Thank you Myra. I used your information in conjunction with this link http://msdn.microsoft.com/en-us/library/ms255816.aspx and succeeded. – starskythehutch May 28 '10 at 10:29
  • Cache folder was the victim, @Myra, thanks for the link :) thumbs-up – Rookie Programmer Aravind Jan 06 '12 at 13:35
0

Need to do 2 things:

  • Unblock the xsd file, in windows do right click in properties a click unblock.
  • Go to visual studio, options, tools, text editor, xml, and check downloads dtd and schemas.
Xtremexploit
  • 319
  • 4
  • 7
-2

These warnings will disappear when you run Visual studio as administrator.