开发C#.NET 2.0 WinForm应用程序.需要应用程序关闭并重新启动自身.
Application.Restart();
Run Code Online (Sandbox Code Playgroud)
上述方法已被证明是不可靠的.
什么是重启应用程序的更好方法?
我有一个按日期字段分组的多列 Crystal 2008 报表,我想防止该组跨列边界拆分。
谷歌搜索一下,这似乎是不可能的——甚至没有人有某种破解方法来伪造它。
这是该问题的图片 - 我希望 26 号星期五都出现在第二栏中。

我已经阅读并谷歌搜索了这方面的所有内容,但似乎无法让它发挥作用。LifetimeManager我根据这些帖子在我的 MVC5 应用程序中为 Unity创建了自定义:
这是我的SessionLifetimeManager
public class SessionLifetimeManager : LifetimeManager
{
private string key = Guid.NewGuid().ToString();
public override object GetValue()
{
return HttpContext.Current.Session[key];
}
public override void RemoveValue()
{
HttpContext.Current.Session.Remove(key);
}
public override void SetValue(object newValue)
{
HttpContext.Current.Session[key] = newValue;
}
}
Run Code Online (Sandbox Code Playgroud)
我只有几种类型,以下是UnityConfig.cs中的相关注册:
container.RegisterType<IEpiSession, EpiSession>(new SessionLifetimeManager(),
new InjectionConstructor(config.AppServerURI, config.PathToSysConfig));
container.RegisterType<IReportRepository, EpicorReportRepository>(new TransientLifetimeManager());
DependencyResolver.SetResolver(new UnityDependencyResolver(container));
Run Code Online (Sandbox Code Playgroud)
请注意,它EpicorReportRepository依赖于IEpiSession通过构造函数注入。
public class EpicorReportRepository : IReportRepository
{
private IEpiSession session;
// DI constructor …Run Code Online (Sandbox Code Playgroud) asp.net-mvc dependency-injection unity-container asp.net-mvc-5
我需要能够在C#.NET Framework应用程序中连接,断开连接并重新连接拨号网络连接.在电话簿中创建连接可能也是有用/必要的.
是否有为C#或.NET编写的任何类或库可以很好地为我提供所有这些功能?任何人都有一些他们愿意分享的代码?
注意:应用程序是无人值守的,就像Kiosk一样,因此需要用户操作是不可接受的.
我有一个无法使用域凭据连接到SQL Server的问题。使用SA凭据可以正常工作,查询将按预期运行。但是,当我使用域凭据时,会出现错误。
这是脚本:
$SQLServer = 'server.domain.com'
$SQLDBName = 'DBname'
$username = "DOMAIN\user"
$password = "password"
$SqlConnection = New-Object System.Data.SqlClient.SqlConnection
#--> With SA, it works, with DOMAIN creds, it does not
#$SqlConnection.ConnectionString = "Server=$SQLServer; Database=$SQLDBName; User ID=sa; Password=SApassword;"
$SqlConnection.ConnectionString = "Server=$SQLServer; Database=$SQLDBName; User ID=$username; Password=$password;"
$SqlCmd = New-Object System.Data.SqlClient.SqlCommand
$SqlCmd.CommandText = 'select count (*) from my.table'
$SqlCmd.Connection = $SqlConnection
$SqlAdapter = New-Object System.Data.SqlClient.SqlDataAdapter
$SqlAdapter.SelectCommand = $SqlCmd
$DataSet = New-Object System.Data.DataSet
$SqlAdapter.Fill($DataSet)
$SqlConnection.Close()
$DataSet.Tables[0]
Run Code Online (Sandbox Code Playgroud)
这是我运行脚本时遇到的错误:
使用“ 1”参数调用“填充”的异常:“建立与SQL Server的连接时发生与网络相关或特定于实例的错误。找不到服务器或无法访问该服务器。请验证实例名称是否正确并且该SQL Server配置为允许远程连接(提供程序:命名管道提供程序,错误:40-无法打开与SQL Server的连接)
在C:\ scripts …