navigation
 Monday, January 04, 2010
I've always been a fan of Commands way back when they were called Actions in the old Delphi days. With .NET, WPF, and Silverlight we have so many new tools available to us. One I’ve been having fun with is behaviors.
 |  |  | 
posted on January 4, 2010  #    by Bary Nusz  Comments [0]
 Monday, March 30, 2009

In my previous posts about binding in code behind with WPF, I talked about my helper class that allowed me to quickly create a dependency property within any class and use a number of static functions to quickly bind dependency properties in code behind. So when I took a look at the binding capabilities in Silverlight 2.0 I was disappointed to find out that much of the binding had been stripped out.

posted on March 30, 2009  #    by Bary Nusz  Comments [1]
 Wednesday, February 11, 2009
 Thursday, December 11, 2008

The Texas gang braved freezing temperatures and got together for a little Christmas dinner and celebrated a great year with Falafel. Our chef gave us a Texas-sized helping of sushi, steak, chicken, shrimp, and calamari. Afterwards we all retired for a bit of ice cream.

DSCN2224

posted on December 11, 2008  #    by Bary Nusz  Comments [0]
 Thursday, October 30, 2008

If you recently got this error when trying to print from your SQL Server Reports page then listen up. We recently started getting this with one of our big report server installations. We hadn't deployed any new reports recently, no recent configuration changes, so why now? I did remember applying a number of Windows updates to one of my development machines the night before. A quick check with the customer client machines revealed that those same Window updates also got applied. So I tried printing a report from one of my other development machines that had not gotten the Windows updates yet - no problem, printed without error. Great, now I just had to figure out which update caused the problem. After applying updates one by one I found the winner!

Cumulative Security Update for Internet Explorer 7 (KB956390)
http://www.microsoft.com/technet/security/bulletin/ms08-058.mspx

The work around was to have the users export the report to PDF and print from the PDF viewer. I decided that I would try to apply these updates to the report server to see if that would fix the problem. Sure enough, all of the clients were able to print now. So if you start getting this error when trying to print from SQL Server Reports, make sure you apply the Windows updates to your report server.

posted on October 30, 2008  #    by Bary Nusz  Comments [1]
 Monday, September 15, 2008
My latest challenge is to learn everything there is about Sitefinity. When I first came to Falafel, one of my first assignments was to update some of Falafel's DNN modules, one of which was QuoteMax. This was a simple module that would manage a list of quotes and would pick one for display upon each page load. Of course, you might have a hard time saying any DNN module development was simple. In any case, this simple control would be my first try at custom Sitefinity development.
 |  |  |  | 
posted on September 15, 2008  #    by Bary Nusz  Comments [2]
 Tuesday, August 26, 2008
With Expression Blend it's quite easy to style your own custom ScrollBar to get the look you want.
 | 
posted on August 26, 2008  #    by Bary Nusz  Comments [0]
 Tuesday, August 12, 2008
In my previous blog about dependency properties, I detailed a helper class that you can add to any non-DependencyObject class to give you access to dependency properties in that class. To start off with, we need to add a couple of new static functions to our helper class to handle adding bindings with converters.
 |  | 
posted on August 12, 2008  #    by Bary Nusz  Comments [3]
 Sunday, July 20, 2008
When your WPF project gets large with a well structured class diagram, you may run into a case where you need to add a dependency property to a class that it is not convenient to inherit from a dependency object. In that case you need a little help from a helper class. I recently ran into this little problem and came up with this class.
 |  |  | 
posted on July 20, 2008  #    by Bary Nusz  Comments [0]
 Saturday, July 12, 2008
So, let's say you've got a UserControl in a project that you would like to reference using interfaces without a direct reference to the UserControl's project. Now say you want to bind to a DependencyProperty in the UserControl. An interface to the UserControl doesn't help with the DependencyProperty. When I tackled this issue, I was unable to find any example of it anywhere on the Internet.
 |  | 
posted on July 12, 2008  #    by Bary Nusz  Comments [0]
 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 [1]
 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 [2]
 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 [2]
 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]