VS Setup Project - SQL Database can't connect

Anel Hodzic 71 Reputation points
2022-04-28T21:06:59.14+00:00

After installation application can't connect to LocalDB file.

What I did wrong

On Setup Project I've added Prerequisites to

  • Microsoft .NET Framework 4.7.2
  • SQL Server 2012 Express
  • SQL Server 2019 Express LocalDB

And Inside my Application Folder , I've added my Database.mdf file.
After installation I got everything in same folder, and Database.mdf is on same location where is my main.exe located.

Under services i have : SQL Server (SQLEXPRESS) up and running.

My app.config

<?xml version="1.0" encoding="utf-8"?>
    <configuration>
        <connectionStrings>
            <add name="fdb_Connection" connectionString="xpoprovider=MSSqlServer;data source=(LocalDB)\MSSQLLocalDB;AttachDBFilename=|DataDirectory|\Database.mdf;integrated security=True" />
            <add name="localConnection" connectionString="Data Source=(LocalDb)\MSSQLLocalDB;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\Database.mdf" providerName="System.Data.SqlClient" />
        </connectionStrings>
        <startup>
            <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
        </startup>
        <runtime>
            <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
                <dependentAssembly>
                    <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
                    <bindingRedirect oldVersion="0.0.0.0-13.0.0.0" newVersion="13.0.0.0" />
                </dependentAssembly>
                <dependentAssembly>
                    <assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
                    <bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
                </dependentAssembly>
            </assemblyBinding>
        </runtime>
    </configuration>

Error i got is :

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 56 - Unable to load the SQLUserInstance.dll from the location specified in the registry. Verify that the Local Database Runtime feature of SQL Server Express is properly installed.)

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
12,678 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,226 questions
.NET Runtime
.NET Runtime
.NET: Microsoft Technologies based on the .NET software framework.Runtime: An environment required to run apps that aren't compiled to machine language.
1,118 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Karen Payne MVP 35,031 Reputation points
    2022-04-28T22:18:27.61+00:00

    Well xpoprovider is for DevExpress, you need to use their support center as this is not a standard connection string setup.

    0 comments No comments