In the process of upgrading your existing DD4T based implementation to latest DD4T 2.0 based implementation, the major effort is required in the Content Delivery side.
You would typically be following below process for upgrading your code/implementation to the DD4T 2.0:
Typically, you would be doing following:
- Removes all references to DD4T 1.31 dlls from each project in your website solution
- Download and Install DD4T packages using NuGet Manager – What all packages you may need to install depends on your specific implementation requirement, however, you would mostly be downloading and installing following packages:
- DD4T.Providers.SDLTridion2013 or DD4T.Providers.SDLTridion2013sp1 or DD4T.Providers.SDLTridion2011
- DD4T.DI.Unity or DD4T.DI.Ninject or DD4T.DI.Autofac – In case you are using a DI mechanism provided by Unity or Ninject or Autofac respectively
- Ensure, all necessary projects now have a reference to these newly downloaded DD4T 2.0.x.x version dlls
Compiling the Solution:
There may be a variety of compile time errors after changing the references to the new DD4T dlls. The magnitude of compile errors and their fixes entirely depends on the implemented code, usage & customization/extending/overriding of DD4T classes/methods and cleanliness of the code. You can get an idea of changes and challenges you might face by referring the below list of typical compile issues I have faced and required a resolution in the code: (The below list may be different in your implementation)
- Change all references of D4T.ContentModel.Logging to DD4T.ContentModel.Contracts.Logging
- Change all references of D4T.ContentModel.Logging.ILogWrapper to DD4T.ContentModel.Contracts.Logging.ILoggers
- Change all references of DD4T.Utils.LoggerService to DD4T.Utils.Logger
- Change all references of DD4T.Providers.SDLTridion2013 to DD4T.Providers.SDLTridion2013sp1
- Change all method calls of GetView(ComponentPresentation) to View(GetViewName(ComponentPresentation))
- Need to re-implement IPage interface for newly added method – IDictionary<string, IFieldSet> ExtensionData
- A variety of DD4T classes now does not have a parameter-less constructor, additionally, most DD4T classes have changes in the constructure signature – This requires a change in all those classes in the implementation inheriting from these DD4T classes.
- PageFactory now does not have a parameter-less constructor and also have its constructor accepting additional parameters – This means if there is any customization/extending of this class, you need to appropriately make changes in that class to support the updated constructor
- TridionControllerBase now does not have a parameter-less constructor and also have its constructor accepting additional parameters – This means if there is any customization/extending of this class, you need to appropriately make changes in that class to support the updated constructor
- Need to change all references to DefaultComponentPresentationRenderer as there is no parameter-less constructor
After all compile errors are resolved, you may come across a variety of run-time errors which also need to be fixed. These run-time errors entirely depends on specific implementations. Few major changes, I experienced while upgrading are as below:
- All references to IComponentProvider must be changed to IComponentPresentationProvider. The IComponentProvider is marked as deprecated in DD4T2.0 so you will not get any compile time error, but actually, all the methods in IComponentProvider are throwing NotImplemented exception.
- Change of IComponentProvider to IComponentPresentationProvider means we also need to change any reference of IComponentFactory to IComponentPresentationFactory
- Above changes suggests, all method calls to GetComponent may need to be changed to GetComponentPresentation.
- Further this means, TryGetComponent would be changed to TryGetComponentPresentation – Please note the parameters order is changed for these two method
- Following new dependencies must be declared for your DI module in use (In my case it was Windsor, so a bit of different process):
There may more or less changes during the run time as well as compile time depending on your specific implementation and code.
BTW – Not to mention the great help from Harald Hoffelinck in identifying and resolving some of these critical issues.