January 2008 Entries

Honestly speaking i was never a fan of TDD till few months back, but the more i read on this topic the more i am facsinated about it. Not untill I read Agile Principles, Patterns and Practices by Robert C Martin, where he talks about the relevance of unit test to validate both design and code smell.

Okies let me brief out some of the new cool features of xUnit.net

Things i liked of xUnit.Net compared to NUnit

  • Single Object Instance per Test Method.
  • No [SetUp] or [TearDown] - replaced by constructor
  • No [ExpectedException] - appropriate exceptions at relevant line of code
  • Aspect-Like Functionality.
  • Reduced the Number of Custom Attributes.  i am fan of AOP

Most liked

  • Use of Generics.
  • Anonymous Delegates.

for further reading refer codeplex

No one expects this kinda issues first thing in the morning :-(, things were undercontrol till last nite before i hit the bed

Here is the exception while exposing service from WSSF Host project

 

Microsoft.Practices.RecipeFramework.ActionExecutionException: An exception occurred during the binding of reference or execution of recipe ExposeWCFService. Error was: Action SetServiceModelEntryAction failed to execute:

The type 'Consensus.Net.PolicyInjectionBehaviors.PolicyInjectionEndpointBehavior, Consensus.Net.PIBehaviors, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' registered for extension 'PolicyEndPointBehavior' could not be loaded. (C:\Documents and Settings\Administrator\Desktop\CoreBooking\Consensus\Tests\Consensus.Net.Host\web.config line 182).

You can remove the reference to this recipe through the Guidance Package Manager. ---> System.Configuration.ConfigurationErrorsException: The type 'Consensus.Net.PolicyInjectionBehaviors.PolicyInjectionEndpointBehavior, Consensus.Net.PIBehaviors, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' registered for extension 'PolicyEndPointBehavior' could not be loaded. (C:\Documents and Settings\Administrator\Desktop\CoreBooking\Consensus\Tests\Consensus.Net.Host\web.config line 182)

   at System.Configuration.BaseConfigurationRecord.EvaluateOne(String[] keys, SectionInput input, Boolean isTrusted, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult)

   at System.Configuration.BaseConfigurationRecord.Evaluate(FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult, Boolean getLkg, Boolean getRuntimeObject, Object& result, Object& resultRuntimeObject)

   at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)

   at System.Configuration.BaseConfigurationRecord.GetSection(String configKey, Boolean getLkg, Boolean checkPermission)

   at System.Configuration.ConfigurationSectionCollection.Get(String name)

   at System.Configuration.ConfigurationSectionCollection.get_Item(String name)

   at System.ServiceModel.Configuration.ServiceModelSectionGroup.get_Services()

   at Microsoft.Practices.SoftwareFactories.ServiceFactory.WCF.Configuration.ServiceModelConfigurationManager..ctor(Configuration configuration)

   at Microsoft.Practices.ServiceFactory.WCF.Actions.Configuration.SetServiceModelEntryAction.Execute()

   at Microsoft.Practices.RecipeFramework.Recipe.Microsoft.Practices.RecipeFramework.Services.IActionExecutionService.Execute(String actionName, Dictionary`2 inputValues)

   at Microsoft.Practices.RecipeFramework.Recipe.Microsoft.Practices.RecipeFramework.Services.IActionExecutionService.Execute(String actionName)

   at Microsoft.Practices.RecipeFramework.Extensions.Coordinators.ConditionalCoordinator.Run(Dictionary`2 declaredActions, XmlElement coordinationData)

   at Microsoft.Practices.RecipeFramework.Recipe.ExecuteActions(IDictionaryService readOnlyArguments, IDictionaryService arguments, ITypeResolutionService resolution)

   --- End of inner exception stack trace ---

   at Microsoft.Practices.RecipeFramework.Recipe.UndoExecutedActionsAndRethrow(Exception ex)

   at Microsoft.Practices.RecipeFramework.Recipe.ExecuteActions(IDictionaryService readOnlyArguments, IDictionaryService arguments, ITypeResolutionService resolution)

   at Microsoft.Practices.RecipeFramework.Recipe.Execute(Boolean allowSuspend)

   at Microsoft.Practices.RecipeFramework.GuidancePackage.Execute(String recipe, IAssetReference reference, IDictionary arguments)

   at Microsoft.Practices.RecipeFramework.GuidancePackage.Execute(IAssetReference reference)

   at Microsoft.Practices.RecipeFramework.RecipeReference.OnExecute()

   at Microsoft.Practices.RecipeFramework.AssetReference.Execute()

   at Microsoft.Practices.RecipeFramework.VisualStudio.RecipeMenuCommand.OnExec()

   at Microsoft.Practices.RecipeFramework.VisualStudio.AssetMenuCommand.Invoke()

Solution :

Open the solution in Notepad and scroll down till the end to check the config entries

GlobalSection(ExtensibilityGlobals) = postSolution
  ServiceContractNamespace = http://Consensus.Net.ServiceContracts/Organisation/2007/12
  FaultContractNamespace = http://Consensus.Net.FaultContracts/2007/09
  DataContractNamespace = http://Consensus.Net.DataContracts/2007/09
  UnLocked = True
  Locked = False
  ISWCFSolution = True

 EndGlobalSection

if missing then manually add the same to the .sln file

Issue with the config entry

an additional tag was added up in the config entry

 <endpointBehaviors>
        <behavior name=" Consensus.Net.PolicyInjectionBehaviors.PolicyInjectionEndpointBehavior">
          <PolicyEndPointBehavior />
        </behavior>
      </endpointBehaviors>

remove the "<PolicyEndPointBehavior />", it should work fine

Note: re-compile the solution before exposing the service again

Happy programming !!!

 

Just finished reading an excellent post from Jonathan Rasmusson, I reckon its a must for any project manager to read .

 

Few weeks ago i was training our offshore team on WCF and WSSF. while the guys were doing hands on, they had noticed that the Generic List what they were returning from WCF service was converted to Array and they had no clue why it was happening.

Answer :

Because web services / WCF Service are platform-agnostic, they need to use the most primitive data types. 

Scenerio 1 :

 what would happen if your web service would be consumed by a .NET 1.x application, where no generics are available.

Scenerio 2 :

How would non .Net applications (J2ee or PHP) will consume the service, which doenst have the knowledge of .Net Generics?

The convertion happens because array is the lowest common denominator.

Is that means that we shouldn't be using generic List<T> in the service, the answer is yes you should :-), Because the Native .net applications can take advantage of the Generic List<T> like windows form application in .Net version 2.0 and above

Note : The webservice / WCF service proxy's are generated on the fly based on the nature of the client your using with. if you use them with Windows Form application you will still see the proxy generated will be with the List objects. where us if you use it in ASP.net application the same interface will be generated with Array.

Happy Programming !!!

Few months back I was trying to integrate web client software factory and web service software factory. I had not much clue on how to do and how its gonna work. I had a chat with few of my friends in Microsoft and other MS Gold partner companies to work out a solution for integration. And guess what the very first reaction from them was why the hell are you trying to use both the factoriesL, I just said thanks and continued digging for solution

 

Issues:

 

Added reference to the service in the ASP.net web application and noticed it didn’t generate proxies correctly and no entries for WCF end points in the web.config file

 

The problem now is I can’t continue to dev the client since the WCF proxy generated was crap and its not gonna work coz of missing config entries.

 

Solution:

 

Added reference to the Module (WCSF) and found a clean generated WCF proxy and  appropriate end point entries in the App.Config file

 

Manually copied the config entries to the ASP.net web.config file and it all worked fine.

 

ASP.NET 2.0 still doesn’t have a provision for SERVICE REFERENCE like any other .Net project template, I still don’t know why they haven’t provided one yet or is there any concrete reason behind this?

 

Note : whenever you modify the service, don’t update reference in the ASP.Net since it will re-write the wrong config entries once again

The Web Service Software Factory (also known as the Service Factory) is an integrated collection of tools, patterns, source code and prescriptive guidance that helps Architects to enforce / streamline constraints to quickly and consistently construct Web services that adhere industry standard architecture and design patterns. The Service Factory provides guidance that addresses many of the challenges associated with building WCF and ASP.NET Web services and the components of a distributed application. These challenges include:

  • Designing WCF and ASMX messages and service interfaces.
  • Creating service contracts from existing WSDL and XSD files.
  • Applying exception shielding and exception handling.
  • Designing business entities in the domain model.
  • Translating messages to and from business entities and service data types(This is still crude, and i dont understand why they dont provide a descent mapping tool like the one comes with biztalk , more over there are no provisions to typecast datatypes which i reckon is must)
  • Designing, building, and invoking the data access layer.
  • Validating many aspects of the service using code analysis.
  • Applying message-level security to WCF services.
  • Migration made easy from asmx to wcf
  • message validation at service layer (Cool stuff).

 Links

Couple of weeks ago i ran into an issue with Entlib 3.1 Common application block versioning  when used with web client software factories

i figured out that repository factory still uses MEL Common 2.0 assembly (the one which comes part of WSSF) and when i migrated my project framework from MEL 2.0 to MEL 3.1 it stared replacing the Common 2.0 to Common 3.1 in the WCF Host bin folder, now the issue is i cannot revert back to my old framework since both WCSF and WSSF makes use of logging, exception etc of MEL 3.1

this might not be best of the solution to overcome this problem, unless untill some one comes up with some bright idea

1 > add the source projects of MEL 2.0 to the solution, for e.g. Cache, Common etc

2> remove the assembly reference for Common from the project

3 > add project reference to the Common, and in the properties "Copy Local" set it to false.

This sholud solve the problem related to "Microsoft.Practices.EnterpriseLibrary.Common.dll'

Now today i did the same for Caching application block with additional couple of steps it works fine

1 > remove binary reference to Caching application block and add the project reference. and in the properties "Copy Local" set it to false

2 > in the caching source project - set the  properties for Common  "Copy Local" set it to false

3 > Modify your App.Config or Web.Config with the following changes

   <section name="cachingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Caching.Configuration.CacheManagerSettings, Microsoft.Practices.EnterpriseLibrary.Caching" />

<cachingConfiguration defaultCacheManager="Cache Manager">
  <cacheManagers>
   <add expirationPollFrequencyInSeconds="60" maximumElementsInCacheBeforeScavenging="1000"
     numberToRemoveWhenScavenging="10" backingStoreName="Null Storage"
     name="Cache Manager" />

  </cacheManagers>
  <backingStores>
   <add encryptionProviderName="" type="Microsoft.Practices.EnterpriseLibrary.Caching.BackingStoreImplementations.NullBackingStore, Microsoft.Practices.EnterpriseLibrary.Caching, Version=3.1.0.0, Culture=neutral, PublicKeyToken=null"
     name="Null Storage" />
  </backingStores>
 </cachingConfiguration>

if you are fan of agile design to keep the solution simple then Just GAC the Common and Cache Assembly, it should work

- Prasanna

I had several people asking me for some details about what exactly is fixed in 3.0 SP1 - so here is some more information.
The .NET Framework 3.0 Service Pack 1 fixes the problems that are described in the following articles in the Microsoft Knowledge Base:
932471 FIX: Error message when you try to open or to create a protected XPS document by using the XPS viewer that is included with the .NET Framework 3.0: "Cannot open this document because your permissions have expired"
932816 FIX: You experience various problems in Windows Workflow Foundation
935314 FIX: You may experience issues with Windows Communication Foundation peer channel connections
935315 FIX: The COM+ application cannot start when you use the COM+ Service Model Configuration tool to expose the COM+ components in the COM+ application
935434 FIX: Error message in FIPS-compliant systems when you use Windows Communication Foundation to serialize generic types: "This implementation is not part of the Windows Platform FIPS validated cryptographic algorithms"
936123 FIX: Error message when you open a workflow by using the workflow designer in Visual Studio 2005: "Error loading workflow"
936512 FIX: A memory leak occurs when you send many messages by using the NetMsmq transport in the .NET Framework 3.0
938758 FIX: The Unload method may stop responding (hang) in a Windows Workflow Foundation project
942520 FIX: You may experience slow performance when you run a Windows Communication Foundation application