0
我正在啓動一個windows服務,該服務需要與我的服務器建立套接字連接才能完成工作。我使服務通過OnStart服務事件上啓動的線程建立連接。它一直工作到今天上午,當我在做出一些更改後再次編譯它時:崩潰了客戶端變量的初始化。這裏是它崩潰的代碼部分:初始化新TcpClient時出現「配置系統初始化失敗」
Try
client = New TcpClient 'the error is here
client.Connect(ip, port)
stream = client.GetStream()
receiver.Start()
tryingconnect_thread.Abort()
Catch ex As Exception
File.WriteAllText("C:\error.txt", ex.Message) 'here it gives me "Configuration system failed to initialize"
System.Threading.Thread.Sleep(10000)
End Try
可以肯定我也嘗試了嘗試捕捉結束Try語句只在它的初始化。 我該如何解決這個問題?
我已經看到過這樣的其他問題,但都沒有工作。
編輯:
這是例外:
System.Configuration.ConfigurationErrorsException: Impossibile inizializzare il sistema di configurazione ---> System.Configuration.ConfigurationErrorsException: Sezione di configurazione authentication non riconosciuta. (C:\Users\Davide\Documents\Visual Studio 2013\Projects\winddsvc\winddsvc\bin\Debug\winddsvc.exe.Config line 8)
in System.Configuration.ConfigurationSchemaErrors.ThrowIfErrors(Boolean ignoreLocal)
in System.Configuration.BaseConfigurationRecord.ThrowIfParseErrors(ConfigurationSchemaErrors schemaErrors)
in System.Configuration.BaseConfigurationRecord.ThrowIfInitErrors()
in System.Configuration.ClientConfigurationSystem.EnsureInit(String configKey)
--- Fine della traccia dello stack dell'eccezione interna ---
in System.Configuration.ClientConfigurationSystem.EnsureInit(String configKey)
in System.Configuration.ClientConfigurationSystem.PrepareClientConfigSystem(String sectionName)
in System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(String sectionName)
in System.Configuration.ConfigurationManager.GetSection(String sectionName)
in System.Configuration.PrivilegedConfigurationManager.GetSection(String sectionName)
in System.Diagnostics.DiagnosticsConfiguration.GetConfigSection()
in System.Diagnostics.DiagnosticsConfiguration.Initialize()
in System.Diagnostics.DiagnosticsConfiguration.get_Sources()
in System.Diagnostics.TraceSource.Initialize()
in System.Net.Logging.InitializeLogging()
in System.Net.Logging.get_On()
in System.Net.Sockets.TcpClient..ctor(AddressFamily family)
in System.Net.Sockets.TcpClient..ctor()
in winddsvc.winddsvc.tryconnect() in C:\Users\Davide\Documents\Visual Studio 2013\Projects\winddsvc\winddsvc\Service1.vb:riga 88
這是配置文件:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<authentication mode="Windows" />
<identity impersonate="true" />
</configuration>
如果您中止線程,所有投注都將關閉。這可能會破壞整個過程的穩定。 – usr 2014-11-02 19:23:05
我知道,但那不是問題 – Dadex 2014-11-02 19:42:24
我知道VB.NET對於'()'有時是草率的,但是你有沒有嘗試過'client = new TcpClient()'?根據錯誤消息,我會看看你的配置文件,看看有沒有東西在那裏。 – Tim 2014-11-02 19:49:42