在asp.net程序中部署sql server compact运行程序链接嵌入数据库时抛出异常,显示“SQL Server Compact is not intended for ASP.NET development. ”。
这个问题可以通过在Global.asax中设置AppDomain属性解决,代码如下:
Global
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;
namespace SqlServerCeWebApp
{
public class Global : System.Web.HttpApplication
{
protected void Application_Start(object sender, EventArgs e)
{
AppDomain.CurrentDomain.SetData("SQLServerCompactEditionUnderWebHosting", true);
}
protected void Application_End(object sender, EventArgs e)
{
}
}
}