papadi Development Blog

.NET and Software Development by Dimitris Papadimitriou 
Filed under

.NET

 

The Workflow Way (e-book)

Workflow Foundation brings a new programming model to the developer's arsenal. Like any new programming model, starting from the good old procedural programming that provided as with methods and function, to the modish parallel and functional programming, the Workflow programming model requires some shifting in the way the developers thinks and designs solutions. In addition to that, WF of .NET 4 is completely redesigned and one of Microsoft's main concerns is to make it a standard part of every developer's toolkit.

To help in this endeavour, Microsoft published a free e-book called 'The Workflow Way'. In the 25 pages of this book you can read how you can employ the Workflow Foundation and get the best things out of it.
Click here to download the e-book.

Filed under  //   .NET   WF  

Comments [2]

Creating a Skype add-on using .NET - Part 1

Skype provides pretty rich API for us developers to create add-ons that can customize it's behaviour. There are a number of ways to use this API and access Skype functionality programmatically. Skype4COM is one of these ways and is the recommended one if you want to create your add-on using .NET. Skype4COM is a wrapper dll that provides Skype functionality into the COM world, therefore also to the .NET world, since .NET can use COM dll libraries.

Skype4COM.dll is located into the Program Files\Common\Skype folder (or Program Files (x86)\Common\Skype in case of x64 version of Windows). It is installed (and registered) there if you install Skype with Extras enabled (this is an option of one of the steps of Skype installation). Once done, you can add a reference to it from your .NET project. Simply right click on your project in the Visual Studio solution explorer, select Add Reference and then click on the COM tab. Skype4COM should be in the list populated there.

Example
Here is a simple (self descriptive) example of accessing Skype functionality from your C# code:

SkypeClass skype = new SkypeClass();
Debug.WriteLine(skype.Friends.Count);

Note that once new SkypeClass() is executed, Skype will warn the end-user that some process is trying to access it. End-user must allow your process to access Skype, else you will get an exception.

x64 operating systems!
Here is something you should take care of! I missed this step and in the beginning and spend quite some time figuring out why SkypeClass fails to be initialized! Since Skype4COM is a x86 (a.k.a. 32 bit) library, your add-in should also be x86 in order to be able to use it. In order to configure your project to produce a x86 executable you need to use the configuration manager of Visual Studio. Click on Build menu and then Configuration Manager. In Active solution platform drop down list, select <New>... and on the dialog that opens select x86 as platform. If you miss performing this steps you will notice the problem only on machines with x64 operating system. If operating system is x86, your .NET executable will run as x86 process anyway so it will succeed in instantiating Skype4COM dll.

Resources
Skype4COM Reference (all things you can do with Skype4COM)
Examples (a number of useful examples in many languages)
Forums (unfortunately you will not find prompt help there. most of the threads remain unanswered for days)

Filed under  //   .NET   Remote Collaboration   Skype   Tools  

Comments [0]

Overriding a small problem with Net.Tcp Port Sharing service and Visual Studio 2010 RC

I installed Visual Studio 2010 RC a couple of days after it became available, after uninstalling the previous installed beta 2. Today I discovered a small problem with Net.Tcp Port Sharing service. The status of the Windows Services console was the one show in the attached screen shot. It appears that the installation didn't update the service and it was still registered with executable that was in the previous version of .NET 4 (beta 2). So when trying to start the service I was getting a File not found error in Windows Event log.

I'm not sure if this was a problem of installation of RC or uninstallation of beta 2. Anyway, fixing the problem was easy. I downloaded .NET Framework 4 RC and executed it with the Repair option selected.

Filed under  //   .NET   Visual Studio  

Comments [1]

Windows Authentication in WCF Services

Click here to download:
WindowsAuthenticationTest.zip (17 KB)

There aren't may things one has to do to enable windows authentication in a WCF service. Actually Windows Authentication is by default enabled when using most of the standard bindings of WCF.

Configuration
The following configuration ensures this anyway (use this configuration both on server and on client side):

  <system.serviceModel>
      <bindings>
          <wsHttpBinding>
              <binding name="test">
                  <security mode="Message">
                      <message clientCredentialType="Windows"/>
                  </security>
              </binding>
          </wsHttpBinding>
      </bindings>
      ...

Server
To get the credentials of the user on server side using the following (password in never included):
var identity = OperationContext.Current.ServiceSecurityContext.PrimaryIdentity;

Client
On client you have two options:
a) Do not ask credentials from the user (Integrated Authentication): The credentials of the current logged on user will be used. This requires that the user is logged on to a Windows Domain that is trusted or is the same with the Domain of the server. There is no special code to write here. Simple instantiate the client proxy and use it.
b) Ask for Windows Credentials from the user: This is useful when you expect that your application will be used by users using machines not registered to known Windows Domains. In this case you have to create a typical log in dialog and ask for user name and password. Username must contain the domain name (Eg. MYDOMAIN\myUserName). Also this requires that the username and password the user will use belong to a domain that is trusted or is the same with the Domain of the server. In this case you also need to write the following line after instantiating your client proxy, and use the credentials you collected from the log in dialog:
clientProxy.ClientCredentials.Windows.ClientCredential = new NetworkCredential("MYDOMAIN\\myUsername", "myPassword");

Important
Patterns and Practices team created an excellent pdf document called 'WCF Security Guidance'. This is a quite big document that describes perhaps all the security scenarios that you might consider. It is organized in such a way that you can find what you are looking for quickly. Check it out!

Filed under  //   .NET   Security   WCF  

Comments [0]

Resharper and RIA Services

(The following are applicable to current Resharper and RIA Services releases (see post date). I'm sure it will be fixed in the future)

Watch it RIA Service users that use Resharper!
RIA Services has a strange way (personal opinion) of doing code generation for references services, instead of using the traditional Service Reference approach. Actually, regardless of Resharper and the problem I'm describing underneath, when I first saw a RIA Services application I was really wondering how this works.
And it seems that Resharper is "wondering" also! That's why if you are using Resharper code inspection and/or intellisense you will notice that the classes that are supposed to be generated by RIA Services are not "visible" in your project. Actually if you do nothing, but just create a new 'Silverlight Business Application' using the Visual Studio template and open then App.xaml.cs you will see the picture bellow.
To fix this you have two options:
  • Disable Resharper completely (Tools>Add-in Manager in Visual Studio)
  • Disable Code Inspection and Intellisense of Resharper and let the Visual Studio do it:
    1. Resharper>Options in Visual Studio...
    2. Environment>Intellisense>General
    3. and Code Inspection>Settings

Filed under  //   .net   silverlight  

Comments [3]

Finally! Create Project, Add New Item and Add Reference dialogs are fast!

I just installed Visual Studio 2010 Beta 2 on my machine. I only had little time to play with it so far but I'm so excited! Finally dialog boxes are fast! I never understood so far why 'Create New Project' and 'Add New Item' were so slow in previous versions! Any why 'Add Reference' was opening .NET Assembly tab by default and not Project tab.
Guess what! Huge improvement in VS 2010! Dialogs open extremely fast and Add Reference shows Project tab by default now. And even if you press COM or .NET tabs they are rendered in a few milliseconds!
Startup time of Visual Studio itself seems also improved!

Filed under  //   .NET   Visual Studio  

Comments [0]

E-commerce modules for DotNetNuke

Some time ago I was involved in a project of creating an online store for a Greek firm. The store was to be implemented using dotnetnuke. I made a research back then to find what was the most appropriate dotnetnuke module for that particular case. I run into a blog post which was presenting some, but the most interesting part was the comments under it. If you search you will find a couple of mine also there.
Its been several months now that I keep getting notifications about new comments on that post. The discussion goes on and on... Its quite interesting, have a look...

Filed under  //   .net   dotnetnuke   web  

Comments [0]

Model - View - ViewModel in Silverlight

I'm trying to find my way into the Silverlight world lately. And one of the most predominant phrases in this world is Model-View-ViewModel pattern or else MVVM. This good old pattern suggests the separation of concerns in the UI tier into the three distinctive layers it's name indicates. I've never dealt with MVVM before and as I said Silverlight is also new to me. Therefore I'm trying to read as much as I can before digging into the code.

The most enlightening article I've read so far is Kathleen Dollard's "Applying Model-View-View Model in Silverlight". Kathleen explains how MVVM can be helpful, how to apply it in Silverlight, but also which MVVM promises can be elusive and which not!

Another article I read during my vacations was Shawn Wildermuth's.

Filed under  //   .NET   Silverlight   Web  

Comments [0]

WCF FAQ

Fellow MVP Shivprasad Koirala put together an excellent series of three articles with Frequently Asked Questions regarding the Windows Communication Foundation. Take a look...

WCF FAQ Part 1 : This is a 20 question FAQ for beginners which explains basic concepts of WCF like End points, contracts and bindings. It also discusses about various hosting methodologies of WCF service. The article finally ends talking about bindings and one ways operations in WCF.

WCF FAQ Part 2 : This FAQ covers 10 questions which talks about concepts like duplex contracts, hosting WCF on different protocols, MSMQ bindings, transaction isolation levels and two way communication. The article finally ends talking about two queues volatile and dead letter queue.

WCF FAQ Part 3 : 10 security related FAQ

Filed under  //   .NET   WCF  

Comments [0]

Finally! Edit and Continue in x64!

To x64 or not to x64? One thing that was troubling me answering this question was the lack of 'Edit and Continue' feature when Visual Studio works under x64 (64 bit) operating system.

'Edit and Continue' allows editing code while being in debug mode and resuming execution without restarting the application. Yes, yes. Some people will argue that this is not a big deal, since 'Edit and Continue' is just a nice to have feature and not that important. I will tell you something. Most of the times these people are web developers that never had the chance to use it, since it was never available when developing on ASP.NET.

Good news! Edit and Continue is available on .NET 4 even when using x64 OS! Still not possible on ASP.NET. Watch my screencast...

Filed under  //   .NET   Screencast   Visual Studio   x64  

Comments [0]