Sql Dependency and SignalR: SqlDependency.Start() must be called prior ….


I got this error: “When using SqlDependency without providing an options value, SqlDependency.Start() must be called prior to execution of a command added to the SqlDependency instance” couple of hours ago and I decided to share.

This error occurs if you didn’t started your SqlDependency or it got closed for some reason.  I usually start it this way in the Global.asax
     

 protected void Application_Start(Object sender, EventArgs e)
 {
   var sConn = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
   SqlDependency.Start(sConn);
 
   // Cache systemwide data in the application object.
   ApplicationAdapter.InitApplicationCache();
 }

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s