VS2010 web deploy the connection string argument cannot be null or empty

旧街凉风 提交于 2019-11-30 16:58:08

This was happening right now to me and I managed to isolate the problem... after manually adding a new SQL Server connection string in my Web.config I started experiencing this very error when trying to deploy to the remote server.

When I opened the web deploy Publish profile in Visual Studio 2012 I noticed under the Settings tab that it had set this option: Use this connection string at runtime (update destination Web.config).

Strangely this was setup automatically by VS 2012...

To solve the problem, just uncheck that checkbox and web deploy should start working again.

In addition to Leniel's answer, in case you are not using SqlClient or Entity Framework Code First and thus do not see the checkbox(es), temporarily set the providerName in your web.config's connection string to System.Data.SqlClient and then go back to your publish settings to uncheck the checkbox(es).

I was having the same issue:

2>C:...\Microsoft.Web.Publishing.targets(4270,5): Error : The 'db-Web.config Connection String' argument cannot be null or empty. 2>C:...\Microsoft.Web.Publishing.targets(4270,5): Error : The 'dbAudit-Web.config Connection String' argument cannot be null or empty. 2>C:...\Microsoft.Web.Publishing.targets(4270,5): Error : The 'dbLog-Web.config Connection String' argument cannot be null or empty.

as I was using:

<connectionStrings>
  <add name="db" providerName="MySql.Data" connectionString="server=mysql.gko.local;user=maindk;database=gavekortet;port=3306;password=123456" />
  <add name="dbLog" providerName="MySql.Data" connectionString="server=mysql.gko.local;user=maindk;database=logs;port=3306;password=123456" />
  <add name="dbAudit" providerName="MySql.Data" connectionString="server=mysql.gko.local;user=maindk;database=audit;port=3306;password=123456;pooling=false" />
</connectionStrings>

and as I read here the issue was regarding the publish profile, I then opened the .pubxml file and I've found:

<ItemGroup>
  <MSDeployParameterValue Include="$(DeployParameterPrefix)db-Web.config Connection String" />
  <MSDeployParameterValue Include="$(DeployParameterPrefix)dbAudit-Web.config Connection String" />
  <MSDeployParameterValue Include="$(DeployParameterPrefix)dbLog-Web.config Connection String" />
</ItemGroup>

add <UpdateDestWebConfig>False</UpdateDestWebConfig> to each node, so it will became:

<ItemGroup>
<MSDeployParameterValue Include="$(DeployParameterPrefix)db-Web.config Connection String">
  <UpdateDestWebConfig>False</UpdateDestWebConfig>
</MSDeployParameterValue>
<MSDeployParameterValue Include="$(DeployParameterPrefix)dbAudit-Web.config Connection String">
  <UpdateDestWebConfig>False</UpdateDestWebConfig>
</MSDeployParameterValue>
<MSDeployParameterValue Include="$(DeployParameterPrefix)dbLog-Web.config Connection String">
  <UpdateDestWebConfig>False</UpdateDestWebConfig>
</MSDeployParameterValue>
</ItemGroup>

simply by deleting this entry, everything was again working...

None of the provided solutions helped me.

I finally discovered that in my local Web.config, there was an empty default connection string called LocalMySqlServer (probably put there by the Mysql.Data NuGet package).

After I removed the highlighted line below I was able to successfully publish.

I had the same problem when i deployed a web application to an Azure web-server. I solved it by creating a new server. On that point i realized that there was another application on that server before. That application used a context-name that was not overritten by the second application so that one kept looking for a connectionstring that was overritten by the second application. I asume clearing your server might solve the problem.

I had exactly the same problem - right out of the blue on VS 2017.

Turns out that it was because I was running VS as Administrator. I closed the app down, restarted normally and all was back to normal.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!