freddes.se

…because I'm a nerd

Archive for the ‘Visual Studio’ tag

Announcement and discovery in WCF 4

without comments

WCF 4 comes with a bunch of new features where I find the service announcement and service discovery really cool. In this article I will implement a couple of services using these new features.

A couple of key words and classes for the scenario are SeviceDiscoveryBehavior, UdpAnnouncemenEndpoint, AnnouncementService. I will describe those classes along the way, but on MSDN you can find more information here: WCF Discovery Overview.

In my previous article I linked to a great article written by Aaron Skonnard, don’t miss it: A Developer’s Introduction to Windows Communication Foundation 4. It covers most of the new features in WCF 4, the simplified configuration, Workflow Services and a bunch of other stuff.

I will describe the scenario below along with a couple of code snippets.
Read the rest of this entry »

Written by Fredde

May 16th, 2010 at 3:30 pm

Sharing DataContracts between WCF Services

without comments

In a previous article, Multiple web service references sharing types, I wrote about sharing types between referenced web services. That article used the old ASP.NET Web Service technique, but nowadays WCF is the technology to use. In this article I will use much the same scenario as in the previous article, Visual Studio 2010 and of course WCF (.NET 4).

I will describe the scenario below, describe what may be an upcoming problem and what can be done to avoid it. Please read the previous article as well, it is much the same solution that is to be presented here.

If you are not familiar with WCF and DataContracts you can read David Chappell’s article here: Introducing Windows Communication Foundation in .NET Framework 4. Aaron Skonnard has written a great article about WCF 4, read it here: A Developer’s Introduction to Windows Communication Foundation 4.

Read the rest of this entry »

Written by Fredde

May 2nd, 2010 at 5:21 pm

Posted in .NET,C#,WCF

Tagged with , , , ,

Update Views through events between their ViewModels

with 2 comments

eventLately I’ve been developing standalone WPF applications using Visual Basic. To make a WPF application somewhat easy to maintain and extend it is extremely important to use some design pattern. The most popular design pattern around when developing WPF applications is the MVVM pattern (Model-View-ViewModel).

Developing a single view application is really really straight forward using the MVVM pattern, but when it comes to multiple views application there is no simple solution to update one or more views from another view and still make the Views and ViewModels behind them loosely coupled. When I say update I mean making some property change in the ViewModels behind the Views to be affected by the change of something in another View or ViewModel.

In this post I will show how I’ve solved the problem using events and delegates. Before I describe my solution, please read about the basics in the MVVM design pattern. There are a lot of good publications around, e.g. THE MODEL-VIEW-VIEWMODEL (MVVM) DESIGN PATTERN FOR WPF and Model View ViewModel (Wikipedia).

To make it easier to understand this post and to make it easier for me to write it, please read the following article if you’re not familiar with WPF data binding and the usage of INotifyPropertyChanged: http://coredotnet.blogspot.com/2006/05/wpf-data-binding-tutorial.html.

Read the rest of this entry »

Written by Fredde

December 4th, 2009 at 9:11 am

Posted in .NET,C#,MVVM,Patterns,WPF

Tagged with , , , ,

Multiple web service references sharing types

with one comment

play_btnIn this article I would like to point out a useful way to accomplish something that would be really easy, but still have been annoying me for the last couple of months. Imagine that you would like to get some data of some type from one web service and pass it on to another. The data types on both server sides are the same, but the compiler won’t let you pass the type from the first service on to the next one. Casting won’t work either, not without implementing some kind of home made casting method.

This is really really annoying, since the scenario stated above is really common in the web service world. I will present a solution to this, using the wsdl command line tool when adding web references instead of the built-in tool in Visual Studio.

Read the rest of this entry »

Written by Fredde

February 16th, 2009 at 11:14 pm

Setup an ASP.NET Web Service Solution (MVC Web Service part 2)

without comments

In this article the actual MVC like design will start to show up. The previous article, , didn’t really have anthing to do with MVC, so let’s begin!

Almost all design patterns will make re-use of code easier, but to accomplish this it is important to setup the Visual Studio Solution in such a way to support this. In the setup I will show here I will make way for re-use and the implementation of the MVC design.

Read the rest of this entry »

Written by Fredde

November 25th, 2008 at 9:30 am

Defining service interface types (MVC Web Service part 1)

without comments

I decided to start the process of creating a web service using an MVC like design pattern by specifying the interface towards the consumers. The interface has to be “nice”, and by that I mean that the parameters and return values should be easy to understand and use.

I will show how to define an XML schema using a third party tool, Liquid XML Studio 2008. These schemas will be used when generating C# classes/types to be used as parameters and return values when defining the web service interface. A result of this is that the web service will look like it uses objects as parameters, but this is only a way to represent the XML documents that may be used as parameters.

Read the rest of this entry »

Written by Fredde

November 16th, 2008 at 6:40 pm

Introduction to an MVC like designed Web Service

without comments

The other day I tried to compose an article about how to design an ASP.NET Web Service using an MVC like design pattern. I ended up with a huge article and decided to rewrite it and split it into a couple of smaller articles. I will try to write these articles as independent of each other as possible.

The idea to this subject came up when attending a course, held by Gabriel Svennerberg (http://www.svennerberg.com), dealing with Javascript, JSON and Javascript libraries such as JQuery and DOMAssistant. I wanted to try out the Ajax support in JQuery consuming web methods exposed by a regular SOAP web service as well as a WCF service. The business logic for these two interfaces were to be the same and their methods should have the same set of parameters, in and out. Therefore I wanted to create a couple of controllers and models to be used from the exposed methods. The methods themselves are the views in this MVC like architecture.

Read the rest of this entry »

Written by Fredde

November 12th, 2008 at 12:42 pm

Windows event log and web applications

with one comment

When developing and running web applications, such as web sites or web services, it is nice and convenient to have some logging from the application. Instead of using a log file it would be nice to be able to use the built-in event log in Windows.

When running or debugging a web application from Visual Studio using the built-in web server, named WebDev.WebServer.EXE when looking in the task manager, it will cause no trouble logging to the event log but when publishing the site or service to a server environment, Windows 2003 Server and IIS, it will cause the application to crash. The IIS log file will show an error, status 500, indicating an internal server error. The application will crash due to insufficient permissions for the application to write to the event log.

Don’t worry! There are a couple of solutions to this and I will present one of them here, with the ability to be treated as a little tool for those who develop .NET web applications.

Read the rest of this entry »

Written by Fredde

September 6th, 2008 at 1:14 pm

Posted in .NET,Tips & tricks

Tagged with , ,

ASP.NET MVC Preview 5 Release

without comments

On the ASP.NET CodePlex web site I found that ASP.NET MVC Framework was released, preview 5, the other day.

As I have written in earlier posts about the MVC Framework I will try it out by using it in one of my hobby projects. So far I haven’t got the time to start this project but soon, really soon…

Read the rest of this entry »

Written by Fredde

September 2nd, 2008 at 5:47 pm

ASP.NET MVC Framework

with one comment

Design patterns are great stuff! If every software developer, project managers and others included, had some basic knowledge about designing software the world would be a better place, almost…

Anyways, when developing an ASP.NET web site it is hard to design it properly by means of presentation, business and data layers. Microsoft tried to help us developers by introducing code behind when ASP.NET was released, but it is still very hard to make a nice and clean separation between GUI and business logic. Therefore Scott Guthrie’s team have been working on the ASP.NET MVC Framework.

Read the rest of this entry »

Written by Fredde

August 27th, 2008 at 10:26 pm