navigation
 Monday, June 02, 2008
Anybody familiar with WPF's storyboard knows that animating with the various UI elements is not a problem at all, but what happens when you want the storyboard to call some code behind? The most important thing to remember about the storyboard is that it can only affect dependency properties. So how do we use this to help us call some code behind?
 |  | 
posted on June 2, 2008  #    by Bary Nusz  Comments [0]
 Tuesday, July 24, 2007

So you have a cool asp.net application and everything is running great. You're running it under NET 2.0 and you're using a report server on the same machine. It may run great for months, and then out of nowhere your web application starts displaying the “Service unavailable” page. It does this until you do an iisreset. Where did this message come from? I recently had to find out for myself. My search lead me to the Event Viewer on the server and five warnings about various system failures that read something like this:

A process serving application pool 'ASP.NET V2.0' suffered a fatal communication error with the World Wide Web Publishing Service.

After the fifth warning I would get the following error:

Application pool 'ASP.NET V2.0' is being automatically disabled due to a series of failures in the process(es) serving that application pool.

After the iisreset, things would go OK, but eventually the above warning/error pattern would repeat. What was going on? Why five warnings, the single error, and then the “Service unavailable” page? Well, when you search for "Application pool 'ASP.NET V2.0' is being automatically disabled due to a series of failures", you get plenty of hits. There are plenty of ways to get these errors. What I ended up finding out was that my report server and my web application were using the same application pool. I would not think this would be a big deal, until I found this tab in the properties of the application pool within the IIS Manager.

Mystery solved. It was doing exactly what it was supposed to do. The Enable rapid-fail protection was enabled and I had gotten five failures within 5 minutes to cause the application pool to be disabled. Let's say your web application calls for a report from your reports server. If your reports server fails for some reason, you can also get a failure with your web application. Since they are both in the same application pool this is two strikes with one failure. A couple more of these and your application pool gets shut down. Lesson Learned. It's good practice to move the web application and reports servers into their own application pools.

posted on July 24, 2007  #    by Bary Nusz  Comments [0]
 Wednesday, May 02, 2007

If you need to monitor your transactional replication with a custom monitoring service, Microsoft has provided some useful tools to help. Recently I was having trouble reliably monitoring my replication, and then I discovered this page.

 

http://msdn2.microsoft.com/en-us/library/ms146951.aspx

 

If you’re using transactional replication there is no better way to monitor its health than using your own tracer token. This is just like inserting a tracer token using the replication monitor utility in SQL Server Management Studio.

 

First you need to create a connection to the server.

 

   server = new ServerConnection(sci); 

 

then create a TransPublication object.

 

    TransPublication transPublication = new TransPublication(publicationName, publicationDBName, server);

 

Call LoadProperties of the new object to make sure that all publications and subscriptions are loaded.

 

   transPublication.LoadProperties(); 

 

Then post the tracer token and call refresh to send it on its way. You need to save the ID of the token so that you can clean it up later.

 

   id = transPublication.PostTracerToken();
   transPublication.Refresh();
 

 

Now that the tracer token is on its way we need to create a publication monitor to look for its return. You have to go through a couple of layers to get to it.

 

   Microsoft.SqlServer.Replication.ReplicationMonitor monitor =

      new Microsoft.SqlServer.Replication.ReplicationMonitor(server);
   PublisherMonitor pub = monitor.PublisherMonitors[publisherMonitor];
   PublicationMonitor publicationMonitor = pub.PublicationMonitors[publicationDBName, publicationName];

Now we need to enumerate all of the tokens in the publication. You must call LoadProperties to refresh this list.

 

   publicationMonitor.LoadProperties();
   ArrayList tokens = publicationMonitor.EnumTracerTokens();
 

 

You can cast the items in the array list to a TracerToken type to find the token we sent with the ID we saved earlier.

 

   TracerToken token = null;
   foreach (TracerToken t in tokens)
   {
      if (t.TracerTokenId == tokenID)
      {
         token = t;
         break;
      }
   }
 

 

Now that we have our token we need to enumerate the tracer token history with this call.

 

   DataSet tth = publicationMonitor.EnumTracerTokenHistory(token.TracerTokenId); 

 

This returns a dataset that you need to parse through to get the data we are interested in. These include distributor latency, subscriber latency, and overall latency. If these values are blank, then the token has not returned yet. You need to then enumerate the tokens and check again. When the token has returned you then need to cleanup. A simple call will do this for us.

 

   publicationMonitor.CleanUpTracerTokenHistory(tokenID);

 

If any part of the replication fails for any reason, the token will fail to return and you know you have a problem.

posted on May 2, 2007  #    by Bary Nusz  Comments [0]
 Wednesday, February 21, 2007

Using is one of those dual use keywords in C#. Everybody uses using at the top of your code file so that you don’t have to type all of those long namespaces. The other use is for taking control over the closing and disposing of objects that support the IDisposable interface. Sometimes a little using goes a long way. One IDisposable class that is a good candidate for using is SqlConnection. Without using code to access a database, you would need to use a try-finally block to make sure you free up the resource.

 

SqlConnection conn = new SqlConnection(ConnectionString);

try

{

            ….

}

finally

{

      conn.Close();

}

 

Using using the code becomes much cleaner and logical.

 

using (SqlConnection conn = new SqlConnection(ConnectionString))

{

….

}

 

Next time you consider using resources, consider using using and clean your code up.

posted on February 21, 2007  #    by Bary Nusz  Comments [0]
 Tuesday, September 05, 2006

I recently ran into a problem with a large DataSet when I set the EnforceConstraints to true. It gave me the error “Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.” without any clue as to where to look or what to do. Googling the problem, I came across a blog by Dave Lloyd with a good method to figure out exactly where the error is. The only problem was the example code was Dimmed. Naturally I un-Dimmed the code and put it in a proper C# format. I then encapsulated it into a nice little static function that returns a NameValueCollection loaded with all of the relevant error info. The info returned tells you what table, what row/column, and what the constraint is.

private static NameValueCollection BuildDataSetErrorInfo(DataSet dataSet)     
        {     
            NameValueCollection errorInfo = new NameValueCollection();     
            errorInfo.Add("DataSetName: ", dataSet.DataSetName);     
            foreach (DataTable table in dataSet.Tables)     
            {     
                DataRow[] rows = table.GetErrors();     
                if ((rows != null) && (rows.Length > 0))     
                {     
                    errorInfo.Add("Table: ", table.TableName);     
                    foreach (DataRow row in rows)     
                    {     
                        errorInfo.Add("Row Error: ", row.RowError);     
                        DataColumn[] cols = row.GetColumnsInError();     
                        if ((cols != null) && (cols.Length > 0))     
                        {     
                            foreach (DataColumn col in cols)     
                            {     
                                errorInfo.Add("Column: ", col.ColumnName);     
                                errorInfo.Add("Column Error: ", row.GetColumnError(col));     
                            }     
                        }     
                    }     
                }     
            }     
            return errorInfo;     
        }   
 
posted on September 5, 2006  #    by Bary Nusz  Comments [0]
 Sunday, August 13, 2006

For those who know me, it will come as no surprise that the first mobile web site that I will cover is a weather site. Although there are many weather sites, few are worth mentioning. http://mobile.wunderground.com/ is absolutely the best weather site for your mobile device. If you’ve been inside all day and hear distant thunder, you can quickly pull up your local radar, check for severe weather warnings, and your forecast. All of these pages are stripped down to just the facts. For more serious weather nerds, radar animations, storm tracks, and a quick view of all severe weather in the nation are available. Mark this site now!

posted on August 13, 2006  #    by Bary Nusz  Comments [0]