小编sac*_*rni的帖子

无法删除数据库,因为它当前正在使用中

我想删除一个数据库.我使用了以下代码,但无济于事.

public void DropDataBase(string DBName,SqlConnection scon)
{
    try
    {
        SqlConnection.ClearAllPools();
        SqlCommand cmd = new SqlCommand("ALTER DATABASE " + DBName + "     SET SINGLE_USER     WITH ROLLBACK IMMEDIATE", scon);
        cmd.CommandType = CommandType.Text;
        scon.Open();
        cmd.ExecuteNonQuery();
        scon.Close();

        SqlCommand cmddrpdb = new SqlCommand("drop database " + DBName + "", scon);
        cmddrpdb.CommandType = CommandType.Text;
        scon.Open();
        cmddrpdb.ExecuteNonQuery();
        scon.Close();
    }
    catch (Exception ex)
    {
        MessageBox.Show("DropDataBase : " +ex.Message);
    }
}
Run Code Online (Sandbox Code Playgroud)

我收到错误,因为它无法删除数据库,因为它当前正在使用中.请帮助我解决上述问题.

c# sql-server asp.net

74
推荐指数
10
解决办法
11万
查看次数

37
推荐指数
1
解决办法
7万
查看次数

Windows服务安装程序无法读取App.Config文件

我在我的项目中添加了App.Config.我有一个安装程序类(ProjectInstaller.cs),它需要从App.config中读取值.我提供钥匙.以下是示例代码:

ConfigurationManager.AppSettings["CONFIG_FILE"]
Run Code Online (Sandbox Code Playgroud)

在Installer类中调用时,我按照上面的代码获取空值.但是在App.Config文件中,存在上述键的值.

c# installer windows-services app-config

6
推荐指数
2
解决办法
2万
查看次数

System.threading.timer无法在Windows服务中运行

我在Windows服务中使用System.threading.timer.但是计时器没有成功执行.下面是代码.

    protected override void OnStart(string[] args)
    {
        try
        {  
        eventLog1.WriteEntry("In OnStart");
        TimeSpan dueMinutes = TimeSpan.FromMinutes(1);
        TimeSpan fromMinutes = TimeSpan.FromMinutes(1);
        System.Threading.Timer timer = new System.Threading.Timer(new TimerCallback(CallBack), null, dueMinutes, fromMinutes);


            /*
        System.Timers.Timer timer = new System.Timers.Timer(5 * 60 * 1000);       
        timer.Elapsed += new System.Timers.ElapsedEventHandler(timer_Elapsed);               
            DBSyncHandler sync = new DBSyncHandler();
            sync.startSync();                 
        */
        }
        catch (Exception ex)
        {
            if (!System.Diagnostics.EventLog.SourceExists("MySource"))
            {
                System.Diagnostics.EventLog.CreateEventSource("MySource", "MyEventLog");
            }
            eventLog1.Source = "MySource";
            eventLog1.Log = "MyEventLog";
            eventLog1.WriteEntry("Error : " + ex.Message);
        }

    }



    public static void CallBack(object sender)
    {

        try …
Run Code Online (Sandbox Code Playgroud)

c# multithreading windows-services timer

4
推荐指数
1
解决办法
7424
查看次数

WCF中超出了最大请求长度

我目前正在使用Wcf应用程序并在跟踪日志中获得上面的mentiooned错误.

下面是Wcf服务的Web.Config.

<bindings>
          <wsHttpBinding>
              <binding name="NewBinding0" closeTimeout="00:50:00" openTimeout="00:50:00" sendTimeout="00:50:00" receiveTimeout="00:50:00" maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647">
                  <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
                  <reliableSession enabled="true" />
                  <security mode="None">
                      <transport clientCredentialType="None" />
                      <message clientCredentialType="Windows" negotiateServiceCredential="true" establishSecurityContext="false" />
                  </security>
              </binding>
          </wsHttpBinding>
      </bindings>       

<diagnostics wmiProviderEnabled="true">
  <messageLogging logEntireMessage="true" logMalformedMessages="true" logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true" />
</diagnostics>
<services>
  <service behaviorConfiguration="DBSyncWcfService.Service1Behavior" name="DBSyncWcfService.DBSyncService">
    <endpoint binding="wsHttpBinding" bindingConfiguration="NewBinding0" name="ABC" contract="DBSyncWcfService.IDBSyncContract" address="http://192.168.5.170:9999/" />
    <host>
      <baseAddresses>
Run Code Online (Sandbox Code Playgroud)

以下是客户端配置.

        WSHttpBinding binding = new WSHttpBinding();
        //binding.ReaderQuotas.MaxArrayLength = 10485760;

        //binding.MaxReceivedMessageSize = 10485760;
        binding.Security.Mode = SecurityMode.None;
        binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None;
        binding.Security.Message.ClientCredentialType = MessageCredentialType.Windows;
        binding.Security.Message.EstablishSecurityContext …
Run Code Online (Sandbox Code Playgroud)

wcf wcf-binding wshttpbinding

3
推荐指数
1
解决办法
2万
查看次数

编辑Xml文件

在不使用LINQ的情况下在.Net中编辑Xml文件的不同方法有哪些.

需要完成以下活动.

  1. 更改元素的InnerText.

  2. 在Xml中更改属性.

问候,

Sachin K.

c# asp.net

2
推荐指数
1
解决办法
62
查看次数

在服务器上启用托管WCF服务

我在服务器上托管了一个WCF应用程序.我需要跟踪服务器上生成的信息,警告和错误.请告诉我需要做的必要更改.还请让我知道如何使用生成的跟踪.

此致,Sachin K.

wcf

2
推荐指数
1
解决办法
4160
查看次数

在ServiceModel客户端配置部分找不到引用contract.in的默认端点元素

我添加了一个名为http://192.168.5.180:8080/intg/CrmWebService.asmx的服务引用.名称为CrmWebProxy.

以下是代码行.

Microsoft.Crm.Accelerator.Cca.SampleServices.CrmWebService.CustomerRecord[] resultWebService = new Microsoft.Crm.Accelerator.Cca.SampleServices.CrmWebService.CustomerRecord[3];
Microsoft.Crm.Accelerator.Cca.SampleServices.CrmWebService.CRMWebServiceSoapClient client = new Microsoft.Crm.Accelerator.Cca.SampleServices.CrmWebService.CRMWebServiceSoapClient();
resultWebService = client.GetCustomerData(firstName, lastName, phoneNumber, email, accountName, accountNo, maxRecords);
Run Code Online (Sandbox Code Playgroud)

我得到了上面提到的错误.但是,如果我在示例应用程序中测试它运行完美.

任何帮助.

c# web-services

2
推荐指数
1
解决办法
2万
查看次数

VS.Net 2008中Windows服务中的控制台输出

我正在使用C#使用Windows服务.我希望在Console中输出一个输出,说Console.WriteLine("Hello").我无法得到它,而我能够成功写入它做一个eventLog Entry.

  eventLog1.WriteEntry("In OnStart");
        try
        {
            Console.WriteLine("Hello");         
            DBSyncHandler sync = new DBSyncHandler();
            sync.startSync();

        }
Run Code Online (Sandbox Code Playgroud)

因此,我无法检查它是否正在写入控制台并执行下面提到的代码.

c# console windows-services

1
推荐指数
1
解决办法
2725
查看次数

运行 ng new 命令时出现 jasmine 版本错误

我在运行 ng new 命令时出错

无法解析依赖关系:来自 karma-jasmine-html-reporter@1.6.0 的错误 peer jasmine-core@">=3.7.1"

silly fetch manifest jasmine-core@>=3.7.1
83 timing idealTree Completed in 8839ms
84 timing command:install Completed in 8849ms
85 verbose stack Error: unable to resolve dependency tree
85 verbose stack     at Arborist.[failPeerConflict] (C:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:1141:25)
85 verbose stack     at Arborist.[loadPeerSet] (C:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:1118:34)
85 verbose stack     at async Arborist.[buildDepStep] (C:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:836:11)
85 verbose stack     at async Arborist.buildIdealTree (C:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:209:7)
85 verbose stack     at async Promise.all (index 1)
85 verbose stack     at async Arborist.reify (C:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\reify.js:130:5) …
Run Code Online (Sandbox Code Playgroud)

node.js npm-install angular-cli

0
推荐指数
1
解决办法
900
查看次数