title: Make assembly from SQL 2016 work in SQL 2017 (ex: Calling Math Parser from SQL Server 2017)
body: <p>I have a stored procedure that needs some complex math expression evaluation.
  There is a formula and this stored procedure evaluates its value.</p>
  <p>It calls an UDF defined as below:</p>
  <pre><code>ALTER FUNCTION [dbo].[udfComputeMath]
      (@inputString [NVARCHAR](MAX))
  RETURNS [NVARCHAR](4000) 
  WITH EXECUTE AS CALLER
  AS 
  EXTERNAL NAME [SMP_Assembly].[SuperMathParser.MathParser].[ComputeMath] 
  </code></pre>
  <p>This is quite old code, it worked just fine since SQL Server 2008 R2 (at least), up to 2016.</p>
  <p>However now we try to update our DB to SQL Server 2017, and this no longer works.</p>
  <p>I get the following error:</p>
  <blockquote>
  <p>Msg 10314, Level 16, State 11, Procedure GetPermitTypeFeesByPermitID, Line 88 [Batch Start Line 0]<br />
  An error occurred in the Microsoft .NET Framework while trying to load assembly id 65536. The server may be running out of resources, or the assembly may not be trusted. Run the query again, or check documentation to see how to solve the assembly trust issues. For more information about this error:</p>
  <p>System.IO.FileLoadException: Could not load file or assembly 'supermathparser, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An error relating to security occurred. (Exception from HRESULT: 0x8013150A) System.IO.FileLoadException:</p>
  <p>at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark&amp; stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)</p>
  <p>at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark&amp; stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)</p>
  <p>at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark&amp; stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection)</p>
  <p>at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark&amp; stackMark, Boolean forIntrospection)    at System.Reflection.Assembly.Load(String assemblyString)</p>
  </blockquote>
  <p>Any idea how can make this work again in SQL Server 2017?</p>
  <p>Thank you</p>