Kevin Grohoske

Senior Software Engineer 
MCPD-WEB, MCPD-WIN, MCSD

Visual Studio 2008 SP1 & Framework 3.5.1 Features Presentation

Friday, March 06, 2009 06:15 | posted by: kevin

At the last Gulf Coast .NET User Group, I presented the following slides. There are a number of great features in Service Pack 1 release of VS 2008 and 3.5.1 Version of the .NET Framework. Here are couple quick things to keep in mind.

  •  VS 2008 SP1 and 3.5.1 Framework are pretty much a lockstep upgrade.
  • I call the framework 3.5.1 because MS released a service pack for the framework soon after releasing 3.5.
  • MVC is not part of this release of the framework and is still a separate install. It will likely be a part of 4.0 Framework due out this year.

Visual Studio SP & .NET 3.5.1 Framework Features Presentation

Tags:

PermaLink   E-Mail Article   RSS Comment Feed  

Using Dictionary Object Params In Your Web Service

Friday, September 07, 2007 04:14 | posted by: kevin

In neither .NET Framework 2.0 or 1.x can dictionary objects be used parameters for web service methods, because they are serializable.

For example the following will compile, but not work:

[WebMethod]public string MyMethod(Dictionary<string></string> CustomArguments)

You will generate the following runtime error when you test the ws:

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NotSupportedException: The type System.Collections.Generic.Dictionary`2[[System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]] is not supported because it implements IDictionary.

Don’t dispair I found a great option that will work!!

On Paul Welter’s Weblog

He has an example of a Serializable Dictionary Object. Copy this code into a new class, change your method signature to:

[WebMethod] public string MyMethod(SerializableDictionary<string></string> CustomArguments) { return "Success"; }

Then to use it copy or reference the class on the client side and simply do the following:

localhost.MyService wsService = new localhost.MyService(); SerializableDictionary<string></string> dict = new SerializableDictionary<string></string>(); //use it like any dictionary object dict.Add("test","me"); //call the method of the web service with the dictionary object serialized wsService.MyMethod(dict);

Note: I have noticed that when I use this method sometimes I will get compile errors that imply that I am trying to pass a DataSet rather than the SerializableDictionary object. To correct this manually go into the references.cs and change the method signatures from DataSet to SerializableDictionary. That should fix the problem.

Tags:

PermaLink   E-Mail Article   RSS Comment Feed