2

At my deployment to Azure Cloud WebRole the f:\approot\bin\MYPROJECT.Web.dll.config file has:

<connectionStrings>
<add name="nsDbContext" providerName="System.Data.SqlClient" connectionString="Server=(localdb)\v11.0;Database=nsvDb.TestOnly;Integrated Security=True;" />
</connectionStrings>

At my project I have this.

"MYPROJECT.Web.csproj":

<Content Include="MYPROJECT.Web.dll.config">
  <CopyToOutputDirectory>Always</CopyToOutputDirectory>
  <SubType>Designer</SubType>
</Content>

"MYPROJECT.Web.dll.config":

<connectionStrings>
    <add name="nsDbContext" providerName="System.Data.SqlClient" connectionString="Server=tcp:*****.database.windows.net,***;Database=db;User ID=****;Password=****;Trusted_Connection=False;Encrypt=True;Connection Timeout=30;" />
</connectionStrings>

"Web.config":

<connectionStrings>
    <add name="nsDbContext" providerName="System.Data.SqlClient" connectionString="Server=(localdb)\v11.0;Database=nsvDb.TestOnly;Integrated Security=True;" />
</connectionStrings>

"Web.Release.config":

<connectionStrings>
    <add name="nsDbContext"
         connectionString="Server=tcp:*****.database.windows.net,***;Database=db;User ID=****;Password=****;Trusted_Connection=False;Encrypt=True;Connection Timeout=30;"
         providerName="System.Data.SqlClient" xdt:Transform="SetAttributes" xdt:Locator="Match(name)" />
</connectionStrings>

It is Azure Tools v2.9 installed. Visual Studio Community 2015 (14.0.24720).

Strangly enough when I build Release it places into my local bin\ the content of my web.config when MYPROJECT.Web.dll.config has CopyToOutputDirectory.

How to set up connection string for WebRole deployed locally and deployed to the cloud? Now my configuration breaks because of the invalid connection string.

PS. I've asked similar question at FileLoadException: Could not load file or assembly in WebRole (recycling instance). But now it does not seem to work.

Community
  • 1
  • 1
Artyom
  • 3,507
  • 2
  • 34
  • 67
  • In order to better understand your config files, why do you have a MyProject.Web.dll.config file? Is that file generated for you or are you manually creating it? – Jason Haley May 18 '16 at 01:17
  • @JasonHaley Created by me. Check out the linked question. Or [this article](https://blogs.msdn.microsoft.com/cie/2015/09/06/cloud-services-roles-recycling-with-the-error-system-io-fileloadexception-could-not-load-file-or-assembly/#comment-1503) – Artyom May 18 '16 at 16:18

0 Answers0