typeinitialiseringsfunktionen for 'system.data.sqlclient.sqlconnection' threw an exeption

Ravnø Data 96 Reputation points

The error occurs in a windows forms application.
It occurs when running the application on windows 11.
The application is developed using Visual studio 2013.
Sql Server data tools 12.0.41012.0

Isn't windows 11 supporting ?

An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,659 questions
Windows 11
Windows 11
A Microsoft operating system designed for productivity, creativity, and ease of use.
8,904 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Jiachen Li-MSFT 28,941 Reputation points Microsoft Vendor

    Hi @Ravnø Data ,
    It may be the problem with app.config settings.
    You need to check your code in app.config file with a format similar to the following..

    <add key ="ConnectionString" value="Data Source=server name;Initial Catalog=db name;User ID= sa;Password= sa"/>  

    If you code this wrongly, typeintialiser error will throw.
    Also if the key name is used different from app.config, also exception will throw.
    Best Regards.
    Jiachen Li


    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

  2. Finn Ravnø 1 Reputation point

    It's a windows forms application.
    Developed in Visual Studio 2013
    .net framework 4.5
    When the application runs, it connects to a mssql database

    It runs without problems on windows 10, but not on windows 11

    0 comments No comments