C#WinForm ClickOnce应用程序不';安装后不能工作
我构建的ClickOnce应用程序成功安装并显示应用程序的登录屏幕。但是,当我提交有效的登录信息时,它不会进入主窗体或任何地方。难道是这条代码禁止它通过吗?目标框架是.NET4.5,实体框架6是数据库层C#WinForm ClickOnce应用程序不';安装后不能工作,c#,.net,winforms,entity-framework,clickonce,C#,.net,Winforms,Entity Framework,Clickonce,我构建的ClickOnce应用程序成功安装并显示应用程序的登录屏幕。但是,当我提交有效的登录信息时,它不会进入主窗体或任何地方。难道是这条代码禁止它通过吗?目标框架是.NET4.5,实体框架6是数据库层 [DllImport("user32.dll")] [return: MarshalAs(UnmanagedType.Bool)] static extern bool SetForegroundWindow(IntPtr hWnd); /// <summary> /// The
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool SetForegroundWindow(IntPtr hWnd);
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
bool mutexCreated = true;
using (Mutex mutex = new Mutex(true, Application.ProductName, out mutexCreated))
{
if (mutexCreated)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
frmLogin loging = new frmLogin();
Application.Run(loging);
if (!loging.UserID.Equals(""))
{
Application.Run(new frmMainScreen() { UserID = loging.UserID});
}
}
else
{
Process current = Process.GetCurrentProcess();
foreach (Process process in Process.GetProcessesByName(current.ProcessName))
{
if (process.Id != current.Id)
{
MessageBox.Show("Another instance of " + Application.ProductName + " is already running.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
break;
}
}
}
}
}
[DllImport(“user32.dll”)]
[返回:Marshallas(UnmanagedType.Bool)]
静态外部bool setforegroundindow(IntPtr hWnd);
///
///应用程序的主要入口点。
///
[状态线程]
静态void Main()
{
bool mutexCreated=true;
使用(互斥互斥=新互斥(true,Application.ProductName,out mutexCreated))
{
if(mutexCreated)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
frmLogin loging=新frmLogin();
应用程序运行(登录);
如果(!loging.UserID.Equals(“”)
{
运行(新的frmMainScreen(){UserID=loging.UserID});
}
}
其他的
{
Process current=Process.GetCurrentProcess();
foreach(Process.getProcessByName(current.ProcessName))中的进程
{
if(process.Id!=current.Id)
{
MessageBox.Show(“另一个“+Application.ProductName+”实例已在运行。”,Application.ProductName,MessageBoxButtons.OK,MessageBoxIcon.Information);
打破
}
}
}
}
}
我想出来了!问题既不是登录也不是主表单,而是实体框架在构造函数上引发异常
我只是关注了博客上的帖子,并补充道:
var type = typeof(System.Data.Entity.SqlServer.SqlProviderServices);
给构造器。现在,它的工作就像一个魅力
谢谢大家的回复