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

Ravnø Data 96 Reputation points
2022-11-07T10:32:17.323+00:00

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 ?

VB
VB
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
    2022-11-08T06:09:30.197+00:00

    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..

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

    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
    2022-11-15T09:49:30.067+00:00

    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