System.TypeInitializationException for SQLConnection only during runtime

0

I created a simple application to get data from a SQL database. During the debugmode everything works fine. After the deployment or during release mode a TypeInitializationException appears for the SQLConnection object. Before I start the SQLConnection I change the user with the ImpersonatedUser technique. The whole application is based on another one, I have created, where i access to the same database with the same user but in this case everything works correct. So I have no idea whats the reason why I get this exception.

Maybe someone can help me with this issue. Thanks in advance!

This the exception:

    System.TypeInitializationException
  HResult=0x80131534
  Nachricht = Der Typeninitialisierer f├╝r "System.Data.SqlClient.SqlConnection" hat eine Ausnahme verursacht.
  Quelle = System.Data
  Stapel├╝berwachung:
   bei System.Data.SqlClient.SqlConnection..ctor()
   bei ALMProjectUser.SQLManager.LoadUsersByUserNameFromServer(String url, String db, String user) in C:\Users\as011989\source\repos\ALMProjectUser\ALMProjectUser\SQLManager.cs: Zeile196
   bei ALMProjectUser.SQLManager.GetUser(String searcheduser) in C:\Users\as011989\source\repos\ALMProjectUser\ALMProjectUser\SQLManager.cs: Zeile48
   bei ALMProjectUser.MainWindow.ReCalcView() in C:\Users\as011989\source\repos\ALMProjectUser\ALMProjectUser\MainWindow.xaml.cs: Zeile62
   bei ALMProjectUser.MainWindow.TxtBoxSearch_KeyDown(Object sender, KeyEventArgs e) in C:\Users\as011989\source\repos\ALMProjectUser\ALMProjectUser\MainWindow.xaml.cs: Zeile51
   bei System.Windows.Input.KeyEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
   bei System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   bei System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   bei System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   bei System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   bei System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
   bei System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
   bei System.Windows.Input.InputManager.ProcessStagingArea()
   bei System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
   bei System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
   bei System.Windows.Interop.HwndKeyboardInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawKeyboardActions actions, Int32 scanCode, Boolean isExtendedKey, Boolean isSystemKey, Int32 virtualKey)
   bei System.Windows.Interop.HwndKeyboardInputProvider.ProcessKeyAction(MSG& msg, Boolean& handled)
   bei System.Windows.Interop.HwndSource.CriticalTranslateAccelerator(MSG& msg, ModifierKeys modifiers)
   bei System.Windows.Interop.HwndSource.OnPreprocessMessage(Object param)
   bei System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   bei System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
   bei System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
   bei System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority priority, Delegate method, Object arg)
   bei System.Windows.Interop.HwndSource.OnPreprocessMessageThunk(MSG& msg, Boolean& handled)
   bei System.Windows.Interop.HwndSource.WeakEventPreprocessMessage.OnPreprocessMessage(MSG& msg, Boolean& handled)
   bei System.Windows.Interop.ThreadMessageEventHandler.Invoke(MSG& msg, Boolean& handled)
   bei System.Windows.Interop.ComponentDispatcherThread.RaiseThreadMessage(MSG& msg)
   bei System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
   bei System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
   bei System.Windows.Application.RunDispatcher(Object ignore)
   bei System.Windows.Application.RunInternal(Window window)
   bei System.Windows.Application.Run(Window window)
   bei ALMProjectUser.App.Main()

Innere Ausnahme 1:
COMException: Schwerwiegender Fehler (Ausnahme von HRESULT: 0x8000FFFF (E_UNEXPECTED))

and here is a screenshot from the code:

SQLConnection

c#
exception
impersonation
sqlconnection
typeinitializeexception
asked on Stack Overflow Nov 29, 2018 by Stalte • edited Nov 30, 2018 by Stalte

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0