Archive for category Uncategorized

Visual Studio 2010 XML Schema Errors–xsd:import


Introduction

I’ve been looking at the option for a Publish and Subscribe web service model for a development project which is starting up at work. The research into the Publish and Subscribe model has had me looking at closely at the WS-BaseNotification specification.

To take a closer look at the standard, and what would be involved in implementing this for the project I downloaded the xml schemas (XSD’s) and web service definition language (WSDL) files for the standard. These files I then loaded up into Visual Studio 2010, and that’s when the “fun started”. These files were including (xsd:import) schemas from over the web, and Visual Studio was getting errors doing this. After a quick browse on the internet, it seemed like a common problem, with some complex solutions.  So, thinking there must be a better way, I started solving the problem, my way.

The Errors

Warning          2          Request for the permission of type ‘System.Net.WebPermission, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089’ failed.

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

The “Fix”

I have found that the simplest way to solve these types of errors is to do the following:

  • Download the xsd file being referenced.
    • Paste the URL into IE and get the xsd file up in the browser.
    • Use File –> Save As. To save a copy of the xsd file into the Visual Studio project directory which you are keeping your source code in.
  • Add the xsd file you just downloaded to the project, and open the xml editor for that file.
  • Right click the editor tab for file you just downloaded, and select the “Copy Full Path”.
  • Then change the xsd:import from:
  <xsd:import namespace="http://www.w3.org/2005/08/addressing"
    schemaLocation="http://www.w3.org/2005/08/addressing/ws-addr.xsd"
  />

To

  <xsd:import namespace="http://www.w3.org/2005/08/addressing"
    schemaLocation="file://visual studio 2010/Projects/Project1/DummyShell/ws-addr.xsd"
  />

  • Tip: You have the file location in the clipboard from the “Copy Full Path”, so you only need to swap the \’s to /’s.
  • This makes the reference to a local copy of the schema file.

I’ve had situations where Visual Studio still gives the System.Security.Permissions.FileIOPermission exception/error after making this change. Restarting Visual Studio seemed to “clean out” the error and everything was fine after the restart.

Conclusion

Importing schemas into other schemas is a very powerful feature of xml schema language, but a real pain with Visual Studio. I’m not sure why things get so difficult, the schema cache which Visual Studio maintains seems to, in part, cause extra confusion. This approach ignores the schema cache altogether. Although I did “copy” the xml schema (xml.xsd) from the cache, into the project as well (one of the consequential dependencies required it).

Advertisements

, , , , , , ,

7 Comments

Parallel Programming in .Net – Resources


Introduction

This may be the first of a series of blog post on Parallel Programming with .Net 4.0. It is a “maybe” at this point in time, in that I intended to get into this topic over the coming weeks, but one never knows what else may crop up.

This started off being a look at the synchronised collections support in .Net 4.0, but I’ve decided that I should include some other topics. The other big inclusions are intended to be:

  • Parallel Looping constructs,
  • Parallel LINQ, which the parallel looping leads into, and
  • The Task Class addition to .Net 4.0 Framework.

When you include those, you pretty much have a Parallel programming .Net 4.0 “in a nutshell”. This series may have the impetus to look into some of the more “esoteric”, “subtle” and all-round deeper issues associated with the development, implementation, testing, and deployment of parallel solutions in .Net. But, wait and see, I could come up with some “gems”, and “pearls of wisdom” on the way.

Resources

This is the start of a list of “good” resources on parallel programming in .Net. I’ll try and post further blog posts on the topic as I find more resources (I’ve some PFD’s salted away on the topic as well I’ll try and dig up).

Parallel Programming with Microsoft .NET This is a MSDN Patterns and Practices publication. It contains very good information on parallel programming.

System.Collections.Concurrent Namespace This is the .Net namespace which contains some very useful “pre- cooked” collections which can be used in concurrent (parallel) programming. My preference is to always look at these collections first, and build my own concurrent collection as a last resort.

System.Threading.Tasks Namespace This is the >net namespace which contains the Task object, and the associated infrastructure built into .Net for running parallel Tasks. Again, my preference is to look here first, and only resort to using the Thread Class as a last resort when things do not fit with supplied .Net support.

Parallel Programming in the .NET Framework This is a “top level” page, which has links to much of the .Net Parallel support.

Threading in C# – Part 5 – Parallel Programming This looks to be very good on LINQ and Parallel aspects which can be invoked in the LINQ context. There is also some details on the Task, and associated .Net Framework classes. I’ll be reading this very carefully (again, it will not for the first time I refer to these pages).

Patterns Of Parallel Programming This is a link to a PFD which contains “much” detail on C# .Net Parallel Programming. I’ve yet to digest this one (118 pages is a bit much for one sitting, I’ll have a couple of “bites at this cherry”).

This is just a start of a list of resources. I’ll post further lists of resources, as I dig into the topics I wish to cover.

, , , , , , ,

4 Comments

%d bloggers like this: