<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Sitecore Xperiences &#187; Sitecore Community</title>
	<atom:link href="https://blog.peplau.com.br/category/sitecore-community/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.peplau.com.br</link>
	<description>The things I&#039;ve seen as a Sitecore Professional</description>
	<lastBuildDate>Sun, 09 Mar 2025 21:54:22 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.1.41</generator>
	<item>
		<title>Sitecore 10.1 Form Send E-mail VS Community Send E-mail</title>
		<link>https://blog.peplau.com.br/sitecore-10-1-form-send-e-mail-vs-community-send-e-mail/</link>
		<comments>https://blog.peplau.com.br/sitecore-10-1-form-send-e-mail-vs-community-send-e-mail/#comments</comments>
		<pubDate>Tue, 30 Mar 2021 20:07:32 +0000</pubDate>
		<dc:creator><![CDATA[Rodrigo Peplau]]></dc:creator>
				<category><![CDATA[Experience Forms]]></category>
		<category><![CDATA[Sitecore Community]]></category>
		<category><![CDATA[Sitecore Modules]]></category>

		<guid isPermaLink="false">http://blog.peplau.com.br/?p=846</guid>
		<description><![CDATA[<div class="lr_horizontal_share" data-share-url="https://blog.peplau.com.br/sitecore-10-1-form-send-e-mail-vs-community-send-e-mail/"></div>Experience Forms debuted in 2017 with the Initial Release of Sitecore 9.0. With the mission to replace &#8220;Webforms For Marketers&#8221; (WFFM), it started pretty small. Lots of features were not available in the beginning, some of them taking several years to arise. To be precise, part of the community still thinks it has a long [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Experience Forms debuted in 2017 with the Initial Release of Sitecore 9.0. With the mission to replace &#8220;Webforms For Marketers&#8221; (WFFM), it started pretty small. Lots of features were not available in the beginning, some of them taking several years to arise.</p>
<p>To be precise, <a href="https://twitter.com/jammykam/status/1370023523742326784" target="_blank">part of the community still thinks it has a long road to catch up with WFFM</a>…</p>
<p><img class=" aligncenter" src="http://gif.co/xxyg.gif" alt="" width="543" height="434" /></p>
<h2>Sending Email Messages with Experience Forms</h2>
<p>One of the biggest gaps was the “Send Email Message” action, not present until very recently in Sitecore 10.1. For more than 3 years, the only supported way was the EXM integration, <a href="https://joaoneto.blog/tutorial-send-email-based-on-field-value-using-exm-forms-and-marketing-automation" target="_blank">as my friend João Neto explains in this post</a>.</p>
<p>Noticed the gap, <a href="https://www.nishtechinc.com/Blog/2018/April/Send-E-mail-Action-to-Sitecore-9-Forms" target="_blank">I implemented a free module to provide the community with this feature</a>. Until these days, this is still my most popular module.</p>
<p>But what are the similarities and differences between the two actions? Today, I take a deep dive into the new feature and compare it with my community module.</p>
<p>&nbsp;</p>
<h2>Installation and Configuration</h2>
<p>The new official action comes out-of-the-box. This is convenient compared to external modules: no packages to install. An advantage to Sitecore!</p>
<p>In both cases, you&#8217;ll need to fill the SMTP settings with a configuration patch file. You can use <a href="https://bitbucket.org/nishtechinc/formssendmail/src/master/FormsSendMail/App_Config/Include/smtp.config" target="_blank">the same patch from my module</a>, with localhost settings – Counterstrike!</p>
<p>&nbsp;</p>
<h2>User Interface</h2>
<p>The new action has a nice GUI to configure the action, enabling content editors to write messages in a nice way.</p>
<p><a href="http://blog.peplau.com.br/wp-content/uploads/01-New-UI.png"><img class="alignnone size-full wp-image-848" src="http://blog.peplau.com.br/wp-content/uploads/01-New-UI.png" alt="01 - New UI" width="955" height="478" /></a></p>
<p>I have to admit, this is much better than having to edit e-mail the templates beforehand.</p>
<p><a href="http://blog.peplau.com.br/wp-content/uploads/02-Old-Module-UI.png"><img class="alignnone wp-image-849" src="http://blog.peplau.com.br/wp-content/uploads/02-Old-Module-UI-1024x509.png" alt="02 - Old Module UI" width="1024" height="509" /></a></p>
<p>&nbsp;</p>
<p>The new GUI also provides token selection, so now you don&#8217;t have to remember the exact field names.</p>
<p><a href="http://blog.peplau.com.br/wp-content/uploads/03-Token-selection.png"><img class="alignnone size-full wp-image-850" src="http://blog.peplau.com.br/wp-content/uploads/03-Token-selection.png" alt="03 - Token selection" width="335" height="282" /></a></p>
<p>Well, well… looks like the team in charge of this implementation worked very hard!  <img src="https://blog.peplau.com.br/wp-includes/images/smilies/icon_smile.gif" alt=":-)" class="wp-smiley" /></p>
<p>&nbsp;</p>
<h2>Keyword replacement with Form Data</h2>
<p>Both actions use the same strategy for data replacement, with field named tokens that are replaced with the respective form data. Sitecore uses the [fieldname] format, while the community uses {fieldname}, which is practically the same.</p>
<p>But again, when it comes to the new GUI and the ability to visually select your tokens from the form fields, the new action is much superior for content editors.</p>
<h3>Keyword replacement oddities</h3>
<p>There are still some oddities with keyword replacement, that could be easy fixes. Who knows if Sitecore will ever get back to this simple, but very important feature? They should.</p>
<h4>No replacement allowed with e-mail fields</h4>
<p>It feels strange that none of the e-mail fields (To, Cc, Bcc, and From) can use token replacement. This makes it impossible to send messages using addresses collected in a form.</p>
<p><a href="http://blog.peplau.com.br/wp-content/uploads/04-Email-fields.png"><img class="alignnone size-full wp-image-851" src="http://blog.peplau.com.br/wp-content/uploads/04-Email-fields.png" alt="04 - Email fields" width="901" height="181" /></a></p>
<p>The “From” field is even more limited, as it does not allow to type e-mail addresses. Instead, the editor should select the submitter in a dropdown. To add new submitters to the list, you have to create new items under the following path:</p>
<blockquote><p>/sitecore/system/Settings/Forms/Meta Data/Address Book/Senders</p></blockquote>
<p>This is a serious limitation: the community module allows tokens in any field. This feature is crucial when you want to send emails to (and from) addresses collected in the form. You can&#8217;t send a message to the submitted address, or to the right department as selected in a dropdown field.</p>
<h4>Defective replacement with the Subject field</h4>
<p>Testing the new action, my first submission failed without any visual feedback. The log file showed this curious message:</p>
<blockquote><p>ERROR [Experience Forms]: The specified string is not in the form required for a subject.</p></blockquote>
<p>This started to make more sense when you look at the way I configured the subject:<a href="http://blog.peplau.com.br/wp-content/uploads/05-Subject-setup.png"><img class="alignnone size-full wp-image-852" src="http://blog.peplau.com.br/wp-content/uploads/05-Subject-setup.png" alt="05 - Subject setup" width="246" height="64" /></a></p>
<p>And the content of the &#8220;Multi” field when I submitted this form:</p>
<p><a href="http://blog.peplau.com.br/wp-content/uploads/06-Subject-in-a-MultiList-field.png"><img class="alignnone size-full wp-image-853" src="http://blog.peplau.com.br/wp-content/uploads/06-Subject-in-a-MultiList-field.png" alt="06 - Subject in a MultiList field" width="229" height="94" /></a></p>
<p>It worked fine when I removed the line breaks, so this bug is due to them. This would be an easy fix for future releases. Keep this in mind when you use tokens in the subject, and you will save some precious debugging time!</p>
<p>&nbsp;</p>
<h2>Compatibility</h2>
<p>The new action is only available from Sitecore 10.1 and higher. The community module is still the easiest way to submit e-mails from 9.0 to 10.0, which ensures its relevancy. At least until most of the Sitecore instances are 10.1+. A good clue is the end of mainstream support, found at the <a href="https://support.sitecore.com/kb?id=kb_article_view&amp;sysparm_article=KB0641167" target="_blank">Sitecore Product Support Lifecycle</a>:</p>
<table class="table table-striped table-hover table-bordered table-sm ">
<thead>
<tr>
<th scope="col">Product</th>
<th scope="col">Mainstream Support End Date</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">Sitecore 10.0</th>
<td>31-Dec-2023</td>
</tr>
<tr>
<th scope="row">Sitecore 9.3</th>
<td>31-Dec-2022</td>
</tr>
<tr>
<th scope="row">Sitecore 9.2</th>
<td>31-Dec-2022</td>
</tr>
<tr>
<th scope="row">Sitecore 9.1</th>
<td>31-Dec-2021</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<h2>Full comparison table</h2>
<p>If you reached the end of this article and are still unsure, here is a “very unbiased” comparison table:</p>
<table class="table table-striped table-hover table-bordered table-sm " style="width: 100%;">
<thead>
<tr>
<th scope="col"></th>
<th scope="col">Sitecore’s Send Email</th>
<th scope="col">Community’s Send Email</th>
</tr>
</thead>
<tbody>
<tr>
<th style="text-align: center;" scope="row">Installation</th>
<td style="text-align: center;"><img class="alignnone" src="https://upload.wikimedia.org/wikipedia/commons/thumb/1/17/Star_rating_5_of_5.png/799px-Star_rating_5_of_5.png" alt="" width="117" height="25" /><br />
Out of the box</td>
<td style="text-align: center;"><img class="alignnone" src="https://upload.wikimedia.org/wikipedia/commons/thumb/f/fa/Star_rating_4_of_5.png/800px-Star_rating_4_of_5.png" alt="" width="127" height="27" /><br />
Installable module</td>
</tr>
<tr>
<th scope="row">Configuration</th>
<td style="text-align: center;"><img class="alignnone" src="https://upload.wikimedia.org/wikipedia/commons/thumb/1/17/Star_rating_5_of_5.png/799px-Star_rating_5_of_5.png" alt="" width="117" height="25" /><br />
Configuration file</td>
<td style="text-align: center;"><img class="alignnone" src="https://upload.wikimedia.org/wikipedia/commons/thumb/1/17/Star_rating_5_of_5.png/799px-Star_rating_5_of_5.png" alt="" width="117" height="25" /><br />
Configuration file</td>
</tr>
<tr>
<th scope="row">User Interface</th>
<td style="text-align: center;"><img class="alignnone" src="https://upload.wikimedia.org/wikipedia/commons/thumb/1/17/Star_rating_5_of_5.png/799px-Star_rating_5_of_5.png" alt="" width="117" height="25" /><br />
Amazing GUI</td>
<td style="text-align: center;"><img class="alignnone" src="https://upload.wikimedia.org/wikipedia/commons/thumb/2/2f/Star_rating_3_of_5.png/800px-Star_rating_3_of_5.png" alt="" width="127" height="27" /><br />
Content Editor</td>
</tr>
<tr>
<th scope="row">Form Data Replacement</th>
<td style="text-align: center;"><img class="alignnone" src="https://upload.wikimedia.org/wikipedia/commons/thumb/f/fa/Star_rating_4_of_5.png/800px-Star_rating_4_of_5.png" alt="" width="127" height="27" /><br />
Replacement oddities</td>
<td style="text-align: center;"><img class="alignnone" src="https://upload.wikimedia.org/wikipedia/commons/thumb/1/17/Star_rating_5_of_5.png/799px-Star_rating_5_of_5.png" alt="" width="117" height="25" /><br />
Total freedom</td>
</tr>
<tr>
<th scope="row">Compatibility</th>
<td style="text-align: center;">Sitecore 10.1 and above</td>
<td style="text-align: center;">Sitecore 9 and above</td>
</tr>
<tr>
<th scope="row">Developer is awesome</th>
<td style="text-align: center;">Yes</td>
<td style="text-align: center;">Yes</td>
</tr>
<tr>
<th scope="row">Developer can sing</th>
<td style="text-align: center;">No</td>
<td style="text-align: center;">Yes</td>
</tr>
</tbody>
</table>
<p>I think it&#8217;s a draw!</p>
]]></content:encoded>
			<wfw:commentRss>https://blog.peplau.com.br/sitecore-10-1-form-send-e-mail-vs-community-send-e-mail/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Corey Peplau wrote this - WFFM conflict with Unity DI and a lesson on how Sitecore community is so amazing</title>
		<link>https://blog.peplau.com.br/corey-peplau-wrote-this-wffm-conflict-with-unity-di-and-a-lesson-on-how-sitecore-community-is-so-amazing/</link>
		<comments>https://blog.peplau.com.br/corey-peplau-wrote-this-wffm-conflict-with-unity-di-and-a-lesson-on-how-sitecore-community-is-so-amazing/#comments</comments>
		<pubDate>Mon, 24 Jul 2017 13:35:09 +0000</pubDate>
		<dc:creator><![CDATA[Rodrigo Peplau]]></dc:creator>
				<category><![CDATA[Bug fixing]]></category>
		<category><![CDATA[Sitecore Community]]></category>
		<category><![CDATA[WFFM]]></category>

		<guid isPermaLink="false">http://blog.peplau.com.br/?p=585</guid>
		<description><![CDATA[<div class="lr_horizontal_share" data-share-url="https://blog.peplau.com.br/corey-peplau-wrote-this-wffm-conflict-with-unity-di-and-a-lesson-on-how-sitecore-community-is-so-amazing/"></div>This blog was since the beginning, a space to share my own experiences with Sitecore development, always trying to bring that something new, not easily seen, or showing my interpretation of common problems. But this time I need to break my own rule and bring a story starred by another person. I’m talking about my [&#8230;]]]></description>
				<content:encoded><![CDATA[<p><span style="font-weight: 400;">This blog was since the beginning, a space to share my own experiences with Sitecore development, always trying to bring that something new, not easily seen, or showing my interpretation of common problems. But this time I need to break my own rule and bring a story starred by another person. I’m talking about my good friend </span><a href="https://twitter.com/sitecorey" target="_blank"><b>Corey Smith</b></a><span style="font-weight: 400;">, the most willful person I ever met. </span></p>
<h2><span style="font-weight: 400;">First a small parable </span></h2>
<p><span style="font-weight: 400;">An engineer was hired to fix a complex machine, which he did in less than an hour by simply twisting a single screw.</span></p>
<ul>
<li style="font-weight: 400;"><span style="font-weight: 400;">How much it cost? Asks the client.</span></li>
<li style="font-weight: 400;"><span style="font-weight: 400;">10 thousand dollars, sir&#8230;</span></li>
<li style="font-weight: 400;"><span style="font-weight: 400;">But that is a lot of money just to twist a screw! I need you to do an invoice with details of your job to justify this price.</span></li>
</ul>
<p><span style="font-weight: 400;">And the invoice listed:</span></p>
<ul>
<li style="font-weight: 400;"><span style="font-weight: 400;">Twist a screw: $ 5.00</span></li>
<li style="font-weight: 400;"><span style="font-weight: 400;">Know what screw to twist: $ 9,995.00</span></li>
</ul>
<p><span style="font-weight: 400;">Corey is a step ahead of this story and managed to not only twist the right screw, but made that remotely, and for free.</span></p>
<h2><span style="font-weight: 400;">The WFFM issue</span></h2>
<p><span style="font-weight: 400;">Everything started when, at my first project as </span><a href="http://www.nishtechinc.com/Blog/2017/July/nish-tech-hires-3rd-SitecoreMVP"><span style="font-weight: 400;">new member of Nish Tech Inc</span></a><span style="font-weight: 400;">, I had to install WFFM 8.2 rev. 170413 (Update-3) up above an existent solution. Starting from there, any MVC WFFM form were dying with the following error:</span></p>
<blockquote><p><span style="font-weight: 400;">Error Rendering Controller: Sitecore.Forms.Mvc.Controllers.FormController, Sitecore.Forms.Mvc. Action: Index: Could not create controller: &#8216;Sitecore.Forms.Mvc.Controllers.FormController, Sitecore.Forms.Mvc&#8217;. The item being rendered is: &#8216;/sitecore/content/Website/Home/Community/Cincinnati&#8217;. The context item is: &#8216;/sitecore/content/Website/Home/Community/Cincinnati&#8217;. The current route url is: &#8216;{*pathInfo}&#8217;. This is the default Sitecore route which is set up in the &#8216;InitializeRoutes&#8217; processor of the &#8216;initialize&#8217; pipeline.</span></p>
<p><span style="font-weight: 400;">  at Sitecore.Mvc.Controllers.SitecoreControllerFactory.CreateController(RequestContext requestContext, String controllerName)</span><span style="font-weight: 400;"><br />
</span><span style="font-weight: 400;">   at Sitecore.Mvc.Controllers.ControllerRunner.GetController()</span><span style="font-weight: 400;"><br />
</span><span style="font-weight: 400;">   at Sitecore.Mvc.Controllers.ControllerRunner.Execute()</span><span style="font-weight: 400;"><br />
</span><span style="font-weight: 400;">   at Sitecore.Mvc.Presentation.ControllerRenderer.Render(TextWriter writer)</span><span style="font-weight: 400;"><br />
</span><span style="font-weight: 400;">   at Sitecore.Mvc.Pipelines.Response.RenderRendering.ExecuteRenderer.Render(Renderer renderer, TextWriter writer, RenderRenderingArgs args)</span></p>
<p><span style="font-weight: 400;">Inner Exception: Resolution of the dependency failed, type = &#8220;Sitecore.Forms.Mvc.Controllers.FormController&#8221;, name = &#8220;(none)&#8221;. Exception occurred while: while resolving. Exception is: InvalidOperationException &#8211; The current type, Sitecore.Forms.Mvc.Interfaces.IRepository`1[Sitecore.Forms.Mvc.Models.FormModel], is an interface and cannot be constructed. Are you missing a type mapping? &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; At the time of the exception, the container was: Resolving Sitecore.Forms.Mvc.Controllers.FormController,(none) Resolving parameter &#8220;repository&#8221; of constructor Sitecore.Forms.Mvc.Controllers.FormController(Sitecore.Forms.Mvc.Interfaces.IRepository`1[[Sitecore.Forms.Mvc.Models.FormModel, Sitecore.Forms.Mvc, Version=8.2.0.0, Culture=neutral, PublicKeyToken=null]] repository, Sitecore.Forms.Mvc.Interfaces.IAutoMapper`2[[Sitecore.Forms.Mvc.Interfaces.IFormModel, Sitecore.Forms.Mvc, Version=8.2.0.0, Culture=neutral, PublicKeyToken=null],[Sitecore.Forms.Mvc.ViewModels.FormViewModel, Sitecore.Forms.Mvc, Version=8.2.0.0, Culture=neutral, PublicKeyToken=null]] mapper, Sitecore.Forms.Mvc.Interfaces.IFormProcessor`1[[Sitecore.Forms.Mvc.Models.FormModel, Sitecore.Forms.Mvc, Version=8.2.0.0, Culture=neutral, PublicKeyToken=null]] processor, Sitecore.WFFM.Abstractions.Shared.IAnalyticsTracker analyticsTracker) Resolving Sitecore.Forms.Mvc.Interfaces.IRepository`1[Sitecore.Forms.Mvc.Models.FormModel],(none)</span></p>
<p><span style="font-weight: 400;">  at Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, Object existing, String name, IEnumerable`1 resolverOverrides)</span><span style="font-weight: 400;"><br />
</span><span style="font-weight: 400;">   at Microsoft.Practices.Unity.UnityContainer.Resolve(Type t, String name, ResolverOverride[] resolverOverrides)</span><span style="font-weight: 400;"><br />
</span><span style="font-weight: 400;">   at Sitecore.Mvc.Controllers.SitecoreControllerFactory.CreateControllerInstance(RequestContext requestContext, String controllerName)</span><span style="font-weight: 400;"><br />
</span><span style="font-weight: 400;">   at Sitecore.Mvc.Controllers.SitecoreControllerFactory.CreateController(RequestContext requestContext, String controllerName)</span></p>
<p><span style="font-weight: 400;">Inner Exception: The current type, Sitecore.Forms.Mvc.Interfaces.IRepository`1[Sitecore.Forms.Mvc.Models.FormModel], is an interface and cannot be constructed. Are you missing a type mapping?</span></p>
<p><span style="font-weight: 400;">  at Microsoft.Practices.ObjectBuilder2.DynamicMethodConstructorStrategy.ThrowForAttemptingToConstructInterface(IBuilderContext context)</span><span style="font-weight: 400;"><br />
</span><span style="font-weight: 400;">   at lambda_method(Closure , IBuilderContext )</span><span style="font-weight: 400;"><br />
</span><span style="font-weight: 400;">   at Microsoft.Practices.ObjectBuilder2.DynamicBuildPlanGenerationContext.&lt;&gt;c__DisplayClass1.b__0(IBuilderContext context)</span><span style="font-weight: 400;"><br />
</span><span style="font-weight: 400;">   at Microsoft.Practices.ObjectBuilder2.BuildPlanStrategy.PreBuildUp(IBuilderContext context)</span><span style="font-weight: 400;"><br />
</span><span style="font-weight: 400;">   at Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context)</span><span style="font-weight: 400;"><br />
</span><span style="font-weight: 400;">   at Microsoft.Practices.ObjectBuilder2.BuilderContext.NewBuildUp(NamedTypeBuildKey newBuildKey)</span><span style="font-weight: 400;"><br />
</span><span style="font-weight: 400;">   at lambda_method(Closure , IBuilderContext )</span><span style="font-weight: 400;"><br />
</span><span style="font-weight: 400;">   at Microsoft.Practices.ObjectBuilder2.DynamicBuildPlanGenerationContext.&lt;&gt;c__DisplayClass1.b__0(IBuilderContext context)</span><span style="font-weight: 400;"><br />
</span><span style="font-weight: 400;">   at Microsoft.Practices.ObjectBuilder2.BuildPlanStrategy.PreBuildUp(IBuilderContext context)</span><span style="font-weight: 400;"><br />
</span><span style="font-weight: 400;">   at Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context)</span><span style="font-weight: 400;"><br />
</span><span style="font-weight: 400;">   at Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, Object existing, String name, IEnumerable`1 resolverOverrides)</span></p></blockquote>
<h2><span style="font-weight: 400;">The greatness of Sitecore community</span></h2>
<p><span style="font-weight: 400;">After some googling I found <a href="http://blogs.perficient.com/microsoft/2016/05/sitecore-wffm-controller-not-found-after-upgrade-to-8-1/" target="_blank">this article</a></span><span style="font-weight: 400;"><a href="http://blogs.perficient.com/microsoft/2016/05/sitecore-wffm-controller-not-found-after-upgrade-to-8-1/" target="_blank"> from Corey Smith</a>, where he describes a similar issue after an upgrade, which he solved by moving his Dependency Injection declaration before the InitializeControllerFactory. I know that recent versions of WFFM are using Dependency Injection, so it sounded like a good clue to start my investigation.</span></p>
<p><span style="font-weight: 400;">But in my case we were using <a href="https://msdn.microsoft.com/en-us/library/dn223671(v=pandp.30).aspx" target="_blank">Unity Dependency Injection</a></span><span style="font-weight: 400;">, nothing registered at Sitecore Pipeline, so I thought &#8211; why not asking Corey himself for an idea? He is a great guy, as per what we’ve seen during his presentation at the Sitecore Usergroup Brazil (<a href="https://www.youtube.com/watch?v=MAwy2DwPPjo&amp;list=PLiIDLKfmzW5izK8HmPcFOHQq3YMl369-n&amp;index=1&amp;t=2874s" target="_blank">video can be seen here</a>).</span></p>
<p>What followed was a real lesson for me, breaking my paradigms of balance between personal and professional life, and showing to my amazed eyes how strong, powerful and great is the Sitecore community in general, and Corey Smith in particular.</p>
<h2><span style="font-weight: 400;">Our investigation</span></h2>
<p><span style="font-weight: 400;">It was 3rd July, I was stuck at the hotel in Cincinnati with my family and this issue to solve. Corey were safe at his home in Atlanta, at the convenient distance of a single click to interrupt the chat. We were texting like crazy thru Twitter private messages. Fortunately, we both had beers at our side, would you do without some?</span></p>
<p>We started focusing at the Unity Dependency Injection setup. Under my App_Start folder I had a class called UnityMvcActivator with following decorations above the namespace:</p>
<blockquote><p><b>[assembly: WebActivatorEx.PreApplicationStartMethod(typeof(UnityWebActivator), &#8220;Start&#8221;)]</b></p>
<p><span style="font-weight: 400;">[assembly: WebActivatorEx.ApplicationShutdownMethod(typeof(UnityWebActivator), &#8220;Shutdown&#8221;)]</span></p>
<p><span style="font-weight: 400;">namespace MyClient.Website.Core.App_Start</span></p>
<p><span style="font-weight: 400;">{</span></p>
<p><span style="font-weight: 400;">    public static class UnityWebActivator</span></p>
<p><span style="font-weight: 400;">    {</span></p>
<p><span style="font-weight: 400;">        public static void Start()</span></p>
<p><span style="font-weight: 400;">        {</span></p></blockquote>
<p><span style="font-weight: 400;">Line in bold is specifically setting the start-up of Dependency Injection. That would be automatically invoking (at some point </span><b>in the Application_Start event</b><span style="font-weight: 400;">) the method Start(). The exact point, however, was a mystery for us, so we managed to increase a little of our control over this. Perhaps changing the order here would make any difference? </span></p>
<p><span style="font-weight: 400;">So we removed the line in bold, then registered the method Start as an Initialize Pipeline </span>processor<span style="font-weight: 400;">. For that, the Start signature had to change into a valid Process method, as seem below:</span></p>
<blockquote><p>public void Process(PipelineArgs args)</p></blockquote>
<p>That way we would be able to control the timing when the DI start-up would occur. Promising? I thought so! However unfortunately, no matter where the registration is made, before or after everything, still the same error was showing.</p>
<h2><span style="font-weight: 400;">Root cause </span></h2>
<p><span style="font-weight: 400;">After digging a bit more, Corey came up with the root cause, and a possible solution. Happens that the controller for WFFM forms (FormController), which is the affected class at the error message, has actually two constructors: one without any parameter</span></p>
<blockquote><p>public FormController()</p></blockquote>
<p>And a second one with more parameters</p>
<blockquote><p>public FormController(IRepository&lt;FormModel&gt; repository, IAutoMapper&lt;IFormModel, FormViewModel&gt; mapper, IFormProcessor&lt;FormModel&gt; processor, IAnalyticsTracker analyticsTracker)</p></blockquote>
<p>When Unity tries to instantiate this class it is automatically choosing the controller with most parameters. And that is making the whole thing blow up to the sky.</p>
<h2><span style="font-weight: 400;">Temporary (quick) solution</span></h2>
<p><span style="font-weight: 400;">The temporary solution we ended up doing was:</span></p>
<ol>
<li style="font-weight: 400;"><span style="font-weight: 400;">Roll back the pipeline modification and allow Unity to registry itself again</span></li>
<li style="font-weight: 400;"><span style="font-weight: 400;">Add the following new line to UnityConfig, RegisterTypes method:</span><span style="font-weight: 400;"><br />
</span></li>
</ol>
<blockquote><p><span style="font-weight: 400;">public class UnityConfig</span></p>
<p><span style="font-weight: 400;">{</span></p>
<p><span style="font-weight: 400;">        public static void RegisterTypes(IUnityContainer container)</span></p>
<p><span style="font-weight: 400;">        {</span></p>
<p><b>            // Workaround to solve WFFM issues</b></p>
<p><b>            container.RegisterType&lt;FormController&gt;(new InjectionConstructor());</b></p></blockquote>
<p><span style="font-weight: 400;">What the line above does is to tell Unity to register, only at the FormController class, the constructor with no parameters. This, however, is an ad-hoc solution which brings a very important indagation: What else are we breaking in Sitecore? What other controllers and dependencies do we need to register? </span></p>
<p>“You will probably find out in production, I suppose” says Corey.</p>
<h2><span style="font-weight: 400;">Appropriate (hard) solution</span></h2>
<p><span style="font-weight: 400;">Best thing to do is to abandon Unity Dependency Injection at this project and have <a href="https://doc.sitecore.net/sitecore_experience_platform/developing/developing_with_sitecore/dependency_injectio" target="_blank">Sitecore’s built-in Dependency Injection</a> (<a href="https://github.com/aspnet/DependencyInjection">Microsoft.Extensions.DependencyInjection</a>) </span><span style="font-weight: 400;">to handle all injections at our system. We are not gaining anything using Unity at this project, but actually we are creating problems. </span></p>
<p><span style="font-weight: 400;">Sitecore’s OOTB Dependency Injection </span><span style="font-weight: 400;">is shipped from factory with all proper Dependency Injection configurations. That means that all Sitecore modules play very nice with it, so the whole issue we are having with Unity, for instance, simply wouldn’t even happen at first place.  </span></p>
<p>Along with that, in Sitecore 8.2, we can do Dependency Injection into pipeline processors, which has always been a requirement at Nish Tech, and is also totally awesome!</p>
]]></content:encoded>
			<wfw:commentRss>https://blog.peplau.com.br/corey-peplau-wrote-this-wffm-conflict-with-unity-di-and-a-lesson-on-how-sitecore-community-is-so-amazing/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
