News

Archives

Blogs

Syndication:

Configuration Manager Setting Causing Error PRJ0019

Recently I ran into an issue with a project failing to build on an automated build server using CruiseControl. When I looked into the build log I saw that the Post-Build project was failing with the error message:

"error PRJ0019: A tool returned an error code from "Performing Post-Build Event..."

This was most frustrating especially since the solution was building without issue on my local development environment.

The Post-Build project was a C++ project that basically called several batch files to unregister/register assemblies, copy resources and supporting files, and place other dependencies in the GAC. I decided to run each of the batch files manually to see if that would provide more information as to why this project was failing. This lead me to determine that the batch file that was placing assemblies in the GAC was the culprit and that it was failing to find a particular assembly. The missing assembly was the output of another project.

The project that was not producing the expected output was another C++ project that called a batch file. This batch process was actually embedding resource files into an assembly and then copying the assembly to the expected location. The real confusion started when I looked back into my Subversion log and noted that nothing had changed in this project in more than 2 months! It was almost as if the project had stopped building altogether. But what would cause that?! The Configuration Manager, obviously!

Checking the solution's Configuration Manager settings, I found that the project that was not producing any output was in fact not selected to be part of the build process when the "Any CPU" platform was selected. This was the problem! I had recently updated the CruiseControl configurations to force the solution to be built targeting the platform "Any CPU". As a result, the project that was at the root of the problem was not configured to be built and the post-build process was failing when it couldn't find what it needed.

  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati


Searching for Files Using the Visual Studio 2008 Command Prompt

I just ran into a scenario where I couldn't find a file in it's expected directory.

I took the next logical step and ran a typical search using Windows Explorer. Unfortunately this search turned up no results.

I then found out about the WHERE utility in the Visual Studio 2008 Command Prompt. Using this utility I was able to display all possible locations of the file on my machine based on a search pattern.

Here's what you do:

  1. Start -> Programs -> Microsoft Visual Studio 2008 -> Visual Studio Tools -> Visual Studio 2008 Command Prompt
  2. Type where [search pattern for the files to match]

Hope that helps!

  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati


jQuery - Rotating Ad Functionality

Recently I was working on a project where the need for rotating ad functionality was needed. The site used Ektron and one of the content blocks was required to rotate between three different pieces of content.

The first go at this resulted in an implementation that used the MooTools javascript framework. This implementation achieved the desired functionality, with the different pieces of content rotating between each other. However, this implementation also resulted in a feature (as we developers like to call them). The Ektron menu items were now generating javascript errors (such as "menu[thisM][0] is undefined" or "nextMenu is undefined"). These javascript errors were being from the WorkArea/java/pop_core.js file.

After some research I found that Ektron was using jQuery, not MooTools, for it's javascript. So I thought to myself, "Why not stay consistent?". I decided to implement the rotating ad functionality using jQuery to see if I could get rid of those javascript errors being generated by the Ektron menus.

Using one of the tutorials on jQuery's site (Tutorials: Scroll Up Headline Reader) as a starting point, I implemented the rotating ad functionality with the following source:

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
        <title>jQuery Rotating Ad</title>
        <style type="text/css">
            #slideshowoutershell
            {
                height: 200px;
                position: relative;
                width: 415px;
            }
           
            .slideshow-item
            {
                height: 200px;
                overflow: hidden;
                position: absolute;
                top: 0;
                width: 415px;
            }
        </style>
        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script>
        <script type="text/javascript">
            var interval_time = 4000; // 3 seconds between changes
            var item_count;
            var item_interval;
            var old_item = 0;
            var current_item = 0;

            $(document).ready(function() {
                item_count = $("div.slideshow-item").size();

                $("div.slideshow-item").each(function(i) {
                    $(this).hide();
                });

                $("div.slideshow-item:eq(" + current_item + ")").fadeIn("slow");

                item_interval = setInterval(item_rotate, interval_time); // time in milliseconds
                $('#slideshow-container').hover(function() {
                    clearInterval(item_interval);
                }, function() {
                    item_interval = setInterval(item_rotate, interval_time); //time in milliseconds
                    item_rotate();
                });
            });

            function item_rotate() {
                current_item = (old_item + 1) % item_count;
                $("div.slideshow-item:eq(" + old_item + ")").fadeOut("slow", function() {
                    $("div.slideshow-item:eq(" + current_item + ")").fadeIn("slow");
                });
                old_item = current_item;
            }
        </script>
    </head>
    <body>
        <h3>Testing of Rotating Ad with jQuery</h3>
        <div id="slideshowoutershell">
            <div id="slideshow-container">
                <div id="item-0" class="slideshow-item" style="background-color: Red;"></div>
                <div id="item-1" class="slideshow-item" style="background-color: Green;"></div>
                <div id="item-2" class="slideshow-item" style="background-color: Blue;"></div>
            </div>
        </div>
    </body>
</html>


After implementing the rotating ad functionality using jQuery, the javascript errors that were being generated by the Ektron menus were resolved and did not occur anymore. For some reason, MooTools was not playing 100% nicely with Ektron. I would be interested if anyone else was able to avoid such javascript errors using Ektron and MooTools together.
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati


Rendering a Control as a String

Have you ever run across a situation where it would be nice to render an ASP.NET control as a string? For example, let's say that you had to dynamically generate a control at runtime and then embed it's HTML within a <div>. Fortunately, all ASP.NET controls expose the RenderControl() method. Don't get too excited just yet, the RenderControl() method doesn't simply return a string. Instead, the RenderControl() method takes an HtmlTextWriter as input and renders the control into it. Not so fast though, we can't just create an HtmlTextWriter object without first having a TextWriter object. So it boils down to a couple of steps, but rendering an ASP.NET control as a string can be accomplished in the following way:

public string RenderControlAsString(Control myCtrl)
{
// Create a StringBuilder to generate the string
StringBuilder sb = new StringBuilder();
using (StringWriter sw = new StringWriter(sb))
{
using (HtmlTextWriter tw = new HtmlTextWriter(sw))
{
// Render the control
myCtrl.RenderControl(tw);
}
}
// Return the control rendered as a string
return sb.ToString();
}
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati


My Favorite Visual Studio Tips

1. Ctrl+Shift+V

Ctrl+Shift+V will cycle through the items in the clipboard ring. This allows you to copy multiple things before even attempting to paste them and then paste them in order at a later point. Keep in mind that the clipboard ring holds up to 20 items.

2. Line Numbers

Line numbers make it much easier to discuss your code with someone else, especially during code reviews or technical demos.

To add line numbers to your code
  • Click Tools menu and select Options...
  • Expand the Text Editor tree item
  • Select the C# (or Basic) tree item
  • In the Display section, check Line numbers
NOTE: The line numbers will be displayed on the left of the text editor.

3. Snippets

Visual Studio has code snippets built in or you can create your own. You can also drag-and-drop sections of code to the Toolbar and use them as snippets.

4. Tab Groups

If you need to work with multiple windows you can group them together using tab groups. Right-click on the window tab and select New Horizontal Tab Group (or New Vertical Tab Group). You can then drag-and-drop other windows to the tab group to add or remove them.

5. Regions

Regions allow you to organize your code in a clean and concise manner. I am a firm believer in the practice of only pulling logic into a method if it will be used more than once. I accomplish this using regions to group sections of code that are related and act like a function but are only executed once. I also use regions to group sections of my objects together (i.e. Fields, Properties, Methods).

To place code within a region, simple place the #region and #endregion tags around the code. For example

public void Foo()
{
#region My Region

// Add code here...

#endregion
}

This would allow the method Foo to be collapsed to look like the following:

public void Foo()
{
My Region

}

6. Auto-complete (Ctrl+Space)

Talk about a time saver! I think once I discovered Ctrl+Space I was unable to type a full word again. Even better, intellisense will display suggestions if there is more than one possibility with what you have already typed.
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati