0
votes

We are using CodeFluent's templating engine to generate custom emails in a custom SharePoint 2013 application. SharePoint 2013 apps are typically forward-compatible with SharePoint 2016, but we've hit a CodeFluent-related roadblock when trying to use our assemblies compiled against SharePoint 2013 in SharePoint 2016.

We get the following error when Template.Run(..) is called in SharePoint 2016 (16.0.0.0 assemblies vs. 15.0.0.0 assemblies in SharePoint 2013):

CF7010: CodeFluent template '' exception using language 'CSharp': c:\windows\system32\inetsrv> "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\csc.exe" /t:library /utf8output /R:"C:\Windows\assembly\GAC_MSIL\CodeFluent.Model.Common\1.0.0.0__1bb6d7cccf1045ec\CodeFluent.Model.Common.dll" /R:"C:\Windows\assembly\GAC_MSIL\CodeFluent.Runtime\1.0.0.0__1bb6d7cccf1045ec\CodeFluent.Runtime.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Xml\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.dll" /R:"C:\Windows\assembly\GAC_MSIL\CodeFluent.Runtime\1.0.0.0__1bb6d7cccf1045ec\CodeFluent.Runtime.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\RLSoft.XtraShare.BusinessLayer\v4.0_3.0.0.0__ee2f606d34db8cb1\RLSoft.XtraShare.BusinessLayer.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_64\System.Web\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Web.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Microsoft.SharePoint\v4.0_16.0.0.0__71e9bce111e9429c\Microsoft.SharePoint.dll" /out:"C:\Users\SvcSpAppPool\AppData\Local\Temp\CFTemplating.Temp4.0.30319.42000\70804\CF_00000000001456124944.null.dll" /D:DEBUG /debug+ /optimize- /warnaserror "C:\Users\SvcSpAppPool\AppData\Local\Temp\CFTemplating.Temp4.0.30319.42000\70804\CF_00000000001456124944.null.cs" Microsoft (R) Visual C# Compiler version 4.6.0081.0 for Microsoft (R) .NET Framework 4.5 Copyright (C) Microsoft Corporation. All rights reserved. c:\Windows\Microsoft.NET\assembly\GAC_MSIL\RLSoft.XtraShare.BusinessLayer\v4.0_3.0.0.0__ee2f606d34db8cb1\RLSoft.XtraShare.BusinessLayer.dll: error CS1701: Warning as Error: Assuming assembly reference 'Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' matches 'Microsoft.SharePoint, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c', you may need to supply runtime policy c:\Windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.SharePoint\v4.0_16.0.0.0__71e9bce111e9429c\Microsoft.SharePoint.dll.

The problem seems to stem from the fact that CodeFluent apparently calls the csc.exe compiler with the /warnaserror flag. Is there a way to customize this behavior so that warnings are not treated as errors?

We've tried using a bindingRedirect entry both in csc.exe.config and in the web.config file of the SharePoint web application, to no avail.

As anyone run into that issue before, and if so, how did you solve it?

1

1 Answers

0
votes

You can add a template directive to your template file and use the treatWarningsAsErrors attribute, something like this:

[%@ template treatWarningsAsErrors="false" %]
.... your template code...