Problem: I was getting below error while working with Push SQL Cache dependency
System.InvalidOperationException: When using SqlDependency without providing an options value, SqlDependency.Start() must be called prior to execution of a command added to the SqlDependency instance.
Solution: As hinted in this error, it occurs if you do not use the SqlDependency.Start method before instantiating the connection object. So the solution is to use SqlDependency.Start method and pass the connection string as parameter.
SqlDependency.Start(_connStr);
// get the connection
using (SqlConnection conn = new SqlConnection(_connStr))
{
}
Hope this helps.
Thanks
Regards,
Sheo Narayan
http://www.dotnetfunda.com