Wednesday, September 13, 2006

.NET Remoting config schema

I've recently been working with .NET Remoting; writing a small distrubuted framework for sending "work packets" across a set of machines. I'm trying to be a good developer by ensuring all compile and schema warnings are fixed. However, no matter what I did, my App.config file was issues warning after warning for misconfigured elements I knew to be correct. Moreover, Visual Studio IntelliSense did not work with remoting application entries within <system.runtime.remoting/>.

This annoyed me somewhat, so I decided to investigate.

I first checked the properties for App.config to see what schema was used. Config files follow the DotNetConfig.xsd schema which, for me, sits in the default installation folder (C:\Program Files\Microsoft Visual Studio 8\Xml\Schemas). I searched for the remoting definition and found the elements and attributes of system.runtime.remoting were missing. A quick Google revealed this was happening to a lot of people. Basically, the schema shipped with Visual Studio is incomplete.

In order to fix this, and being lazy and not knowing too much about XML Schemas, I constructed a sample .xml file using all the elements defined in the Microsoft schema reference (http://msdn2.microsoft.com/en-us/library/z415cf9a.aspx). Then, using the XML->Create Schema feature of Visual Studio, I generated the relevant schema definitions. I then added attribute information for each element defined in the schema reference to this output. This produced a complete (to the best of my knowledge) definition of system.runtime.remoting. I then replaced the element definition within DotNetConfig.xsd (being careful to copy the vs:help info into the element definition). NOTE: make a backup copy of your existing DontNetConfig.xsd first.

Anyway, after all this hoop jumping, I now have a working system.runtime.remoting schema that removes all the warnings. Intellisense also works.

Here is a copy of the fixed DotNetConfig.xsd. Hopefully others will find this useful.

6 comments:

Anonymous said...

Hello Simon,

Thanks a lot for posting your modified schema file, it saved my day of hardwork !!

I found it really helpful.

Jigar Mehta
http://jigar-mehta.blogspot.com

Anonymous said...

Can you please tell me if you were using VS2005 there or is the scehma for VS2003 ? I mean Framework 1.1 or 2.0 has been used for schema ?

Simon Chapman said...

This was for .NET Framework 2.0. Sorry, I should have made that clear in the post.

Unknown said...

Thank you very much for your efforts on this. I have been struggling to find the information to generate the schema and this has helped greatly.

peredur said...

Sorry I'm rather late to the party, Simon, but I notice that you have under <system.runtime.remoting> a choice between <application>, <channels>, <channelSinkProviders>, <customErrors> and <debug>. However, as far as I know, it's perfectly legal to have both <application> and, say, <customErrors> (in fact, our applications here demand it). Shouldn't this use <xs:all> or something? I'm no XML expert so that may not be the right solution at all.

Peredur - also from Cardiff.

Unknown said...

This blog post has a full schema for system.runtime.remoting:

http://social.msdn.microsoft.com/Forums/en-US/netfxremoting/thread/dd926b37-eb0b-4695-b0f6-bd6c158eee72