我最近尝试将其 DAL 由 SubSonic 2.2 生成的 .net 2.0 项目升级到 Visual Studio 2010 下的 .NET 4.0。
项目转换没有错误,但现在当我尝试启动它时收到一条相当糟糕的错误消息。
System.Security.VerificationException: Operation could destabilize the runtime.
at SubSonic.DataProvider.ApplyConfig(NameValueCollection config, Boolean& 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)
抛出异常的代码:
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]);
}
}
它执行与此处类似的调用,唯一的区别是它严格来说是一个字符串,而不是它正在操作的布尔值。
private static void ApplyConfig(System.Collections.Specialized.NameValueCollection config, ref string parameterValue, string configName)
{
if(config[configName] != null)
{
parameterValue = config[configName];
}
}
config 定义为 System.Collections.Specialized.NameValueCollection 具有 3 个键 generateNullableProperties, connectionStringName, generatedNamespace extractClassNameFromSPName == false
EDIT1: 启动错误的代码在 Global.asax 的 Application_Start() 方法中
System.Data.SqlClient.SqlDependency.Start(SystemSetting.Schema.Provider.DefaultConnectionString);
EDIT2:错误冒泡导致引用我的 web.config 的 targetinvocation 错误
<SubSonicService defaultProvider="appPlan">
<providers>
<clear/>
<add name="appPlan" type="SubSonic.SqlDataProvider, appPlan.Server.DAL.SubSonic" generateNullableProperties="false" connectionStringName="appPlan" generatedNamespace="appPlan.Server.DAL"/>
</providers>
</SubSonicService>
有没有其他人遇到过这样的问题?我可以升级到 SubSonic3.x,但我相信这将是一项更大的任务。
谢谢。