title: System.Security.VerificationException: Operation could destabilize the runtime. (Subsonic 2.2)
body: <p>I recently tried to upgrade a .net 2.0 project which had its DAL generated by SubSonic 2.2 to .NET 4.0 under Visual Studio 2010.</p>
  
  <p>The projects converted without error but now I am getting a rather vile error message when I try to launch it.</p>
  
  <pre><code>System.Security.VerificationException: Operation could destabilize the runtime.  
  
  at SubSonic.DataProvider.ApplyConfig(NameValueCollection config, Boolean&amp; parameterValue, String configName) in C:\Documents and Settings\Desktop\4.0 Production\rel_1.0\server\Server.DAL\Server.DAL.SubSonic\DataProviders\DataProvider.cs:line 955
     at SubSonic.DataProvider.Initialize(String name, NameValueCollection config) in C:\Documents and Settings\Desktop\4.0 Production\rel_1.0\server\Server.DAL\Server.DAL.SubSonic\DataProviders\DataProvider.cs:line 916
     at System.Web.Configuration.ProvidersHelper.InstantiateProvider(ProviderSettings providerSettings, Type providerType)
  </code></pre>
  
  <p>The code where it is throwing the exception:</p>
  
  <pre><code>    ApplyConfig(config, ref extractClassNameFromSPName, ConfigurationPropertyName.EXTRACT_CLASS_NAME_FROM_SP_NAME);
  
      private static void ApplyConfig(System.Collections.Specialized.NameValueCollection config, ref bool parameterValue, string configName)
      {
          if(config[configName] != null)
          {
              parameterValue = Convert.ToBoolean(config[configName]);
          }
      }
  </code></pre>
  
  <p>It performs similar calls to here, the only difference being it is strictly a string and not a boolean it is manipulating.</p>
  
  <pre><code>private static void ApplyConfig(System.Collections.Specialized.NameValueCollection config, ref string parameterValue, string configName)
  {
      if(config[configName] != null)
      {
          parameterValue = config[configName];
      }
  }
  </code></pre>
  
  <p>config is defined as a System.Collections.Specialized.NameValueCollection with 3 keys
  generateNullableProperties, connectionStringName, generatedNamespace
  extractClassNameFromSPName == false</p>
  
  <p><strong>EDIT1:</strong>  The code that kicks off the error is in the Application_Start() method of the Global.asax</p>
  
  <pre><code>System.Data.SqlClient.SqlDependency.Start(SystemSetting.Schema.Provider.DefaultConnectionString);
  </code></pre>
  
  <p><strong>EDIT2:</strong> The error bubbles out to thowing a targetinvocation error referening my web.config</p>
  
  <pre><code>&lt;SubSonicService defaultProvider="appPlan"&gt;
      &lt;providers&gt;
          &lt;clear/&gt;
          &lt;add name="appPlan" type="SubSonic.SqlDataProvider, appPlan.Server.DAL.SubSonic" generateNullableProperties="false" connectionStringName="appPlan" generatedNamespace="appPlan.Server.DAL"/&gt;
      &lt;/providers&gt;
  &lt;/SubSonicService&gt;
  </code></pre>
  
  <p>has anybody else ever run across such an issue?  I could upgrade to SubSonic3.x but it would be a much greater undertaking I believe.</p>
  
  <p>thanks.</p>