I have seen some issues before with |DataDirectory| and ClickOnce deployment. See the suggestion here:
http://stackoverflow.com/questions/19252480/invalid-value-for-attachdbfilename[
^] to replace the |DataDirectory| during deployment.
This is the code in VB.NET (from the link provided):
Dim dataDir As String
If ApplicationDeployment.IsNetworkDeployed Then
Dim ad = ApplicationDeployment.CurrentDeployment
dataDir = ad.DataDirectory
Else
dataDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)
End If
The equivalent code in C# would be:
string dataDir;
if (ApplicationDeployment.IsNetworkDeployed)
{
var ad = ApplicationDeployment.CurrentDeployment;
dataDir = ad.DataDirectory;
}
else
{
dataDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
}