Chris Eargle

Life Student of the Kodefu Arts

MSI Compilation Error

by chris 24. July 2008 10:13

While building a new Web Deployment project, I received the error "Unable to build project output group 'Content Files from (Active)." I checked all of my settings and everything seemed to be correct.

I found a support article on Microsoft's Help and Support site describing why this occurs. Apparently, if you have missing files in your project this will happen. In this case, it turns out that a folder of images had been moved in the source tree but not in the project file. This was causing them to all show the the yellow exclamation symbol. Even though the project has "warnings as errors" turned on, the compiler will not complain about missing content files since it does not need to do anything with them.

If you get the error, quickly scan the project you're deploying for any missing files. It will be a file with the Build Action set to Content.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

msi, deployment

Kodefu

E-mail | Kick it! | DZone it! | del.icio.us
Permalink | Comments (0) | Post RSSRSS comment feed

Moving Parts and Timeouts

by chris 15. June 2008 16:41

Last week I was tasked with changing our build script from using sql scripts to build the database, to running sql scripts to backup and restore a "gold standard" database. Aside from a few permission issues, things went mostly well. However, in the process I updated MSBuild Community Tasks to the nightly build version. I had an error I thought it might help with, but it turned out not to be the case. I kept the unreleased version in production because it generated clearer messages in the ExecuteDDL task. For those of you that don't know, version 1.2.0.306 gives truly awful information in the event a sql script fails.

Fast forward to tonight. I had to roll out a demonstration version of the software from the previous iteration. This meant changing views in the source control system so it would execute the previous versions scripts. When I ran it, received this error (traceable info changed): C:\MyData\Project\base\src\Project.proj (1550,3):  error : ProjectCDDB: Error # -2 on Line 0: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.

I used the ultracool "MSBuild Output" report to get color coding so I could easily trace down which file was causing the error. I then looked at it's size. Sure enough, it was a beast. But it used to run, and it worked when I manually executed it, so what was different? MSBuild Community Tasks, of course.

I pulled down the latest source and opened up ExecuteDDL. Sure enough, there was a new property in the class... StatementTimeout, defaulted to 30 seconds. That's probably not the best timeout for a sql script that exceeds 5 megabytes.

I changed the timeout to 120 seconds; yet another problem solved. I suppose this sort of thing is bound to happen when you're changing version of libraries and then forced to use chronomancy to pretend it's a month in the past.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

msbuild

Kodefu

E-mail | Kick it! | DZone it! | del.icio.us
Permalink | Comments (0) | Post RSSRSS comment feed

Fun with COM Accessibility

by chris 5. January 2008 19:02

If you're registering your .NET assembly for use in COM, there are a couple of traps that you should be aware of.

You create a class library, make your nifty class you want to instantiate from JavaScript, and compile it. Then you open up the bin folder in Visual Studio Command Prompt:

regasm.exe MyControls.dll

But it doesn't seem to do anything.

""RegAsm : warning RA0000 : No registry script will be produced since there are no
 types to register."

There are three things to check if this happens.

  1. Make sure your library marked ComVisible. Open up AssemblyInfo.cs, and make sure you have [assembly: ComVisible(True)]. If you only want a specific class to be visible, put a [ComVisible(True)] attribute above the class.
  2. Make sure your class is public.
  3. This is the one that seems to catch people off guard. You must have a parameterless constructor for your class. If you have added another constructor, be sure to explicitly declare the parameterless constructor.

After you've checked on those three items, the class should register successfully. Unless you set the ProgId attribute, the class by default will be "Namespace.ClassName."

Unfortunately, this may not be the end of it. If you want to use this within Internet Explorer, particularly if it's a nonvisible control, you may receive a warning about running unsafe ActiveX object. Even after you click the yellow bar at the top and tell it to run, it will fail:

"Automation server can't create object".

Searching around the Internet, I discovered that you need to implement the IObjectSafety interface. But the easiest solution is to give your assembly a strong name.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

com, regasm, activex

Kodefu

E-mail | Kick it! | DZone it! | del.icio.us
Permalink | Comments (0) | Post RSSRSS comment feed

Taking the Ding out of Alt

by chris 20. November 2007 21:52

Grabbing the KeyDown event of a Windows Form is a great way to implement behavior that depends on keyboard input. However, it has this annoying tendecy to "ding" if you use the alt key. Investigating this interesting behavior, I discovered that it occurs before the KeyDown event is raised. Luckily, there is a method that can be overridden to implement the proper code and handle it before it reaches the noisy underbelly of WinForms. The following code snipped illustrates grabbing alt-d. To use it with another key stroke, replace Keys with the ones you want.

protected override bool ProcessCmdKey(ref Message msg, Keys keyData)

{

if (keyData == (keyData | Keys.Alt | Keys.D))

{

//Do Something

return true;

}

return base.ProcessCmdKey(ref msg, keyData);

}

It is important that the base method only be called if your override is not handling the key press.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

c#, winforms

Kodefu

E-mail | Kick it! | DZone it! | del.icio.us
Permalink | Comments (0) | Post RSSRSS comment feed

Better Font for VS2005

by chris 4. October 2007 10:23

If you're running Visual Studio 2005 on Windows XP, you probably aren't too satisfied with the default font. Courier New isn't exactly the easiest font on the eyes. However, options are limited due to the need for mono-spacing.

Microsoft made up for this by distributing Consolas with Vista, so I recommend switching to it. If you're on XP, you have a little bit of work to do.

First, make sure your ClearType font-smoothing is turned on. You can use the ClearType tuner here. Then, download and run Consolas Font Pack for Microsoft Visual Studio 2005.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

visual studio, consolas, font

Kodefu

E-mail | Kick it! | DZone it! | del.icio.us
Permalink | Comments (0) | Post RSSRSS comment feed

Usability Nightmares

by chris 2. October 2007 14:29

Smashing Magazine has a great article called 10 Usability Nightmares You Should Be Aware Of.

The author goes over ten design faux pas you should avoid when designing your website. Many of them are horrible, yet I know I come across them all the time.

  1. Hidden log-in link.
  2. Pop-ups for content presentation.
  3. Dragging instead of vertical navigation.
  4. Invisible links.
  5. Visual noise.
  6. Dead end.
  7. Content blocks layering upon each other.
  8. Dynamic navigation.
  9. Drop-Down Menus.
  10. Blinking images.

There is a list of things you should do at the end of the article:

  1. You don’t use pop-ups.
  2. You don’t change users’ window size.
  3. You don’t use too small font sizes.
  4. You don’t have unclear link text.
  5. You don’t have dead links.
  6. You have at most one animation per page.
  7. You make it easy to contact you.
  8. Your links open in the same window.

I disagree with the last one. I think it is perfectly okay to open external links in a new window, although I would agree with that point for internal links. In the era of tabbed browsing, using new windows (tabs) for external links makes it easier for users to return to the site at the point they were reading.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

web, usability, design

Kodefu

E-mail | Kick it! | DZone it! | del.icio.us
Permalink | Comments (0) | Post RSSRSS comment feed

Format Solution

by chris 14. August 2007 19:14

There's a cool option in Visual Studio 2005 to format the current document (ctrl-e,d). But what do you do when you have thousands of files in your C# solution? I'm much too lazy to open every file individually to make sure other developers on the project are formatting their code properly.

My first idea was to change the build script. Doing this would ensure the code is always formatted (unless someone has a lock). Unfortunately, I could find no task do this in MSBuild. Naturally, I endeavored to build my own, but after trying to figure out the VS SDK I decided I should review other options. I chose to look into a macro since the command is already present within Visual Studio.

A quick google search brought me to Kevin Pilch-Bisson's blog explaining why the VS team didn't give a "Format Solution" option: "we figured that if you were consistently using VS, there wouldn’t be much need, since the formatting should be right already." I guess they didn't calculate large projects with developers who may not format habitually.

Kevin goes on to explain how he ended up needing the functionality and coded a macro for it. I tried using his macro, but it didn't like the way the solution was structured. In the solution I'm working on, there are several projects in subfolders within the solution. When stepping through the code I discovered you had to drill down into the SubProject property of some projects.

Here's my fixed version:

Public Sub FormatSolution()

Dim sol As Solution = DTE.Solution

For i As Integer = 1 To sol.Projects.Count

FormatProject(sol.Projects.Item(i))

Next

End Sub

Private Sub FormatProject(ByVal proj as Project)For i As Integer = 1 To proj.ProjectItems.Count

FormatProjectItem(proj.ProjectItems.Item(i))

Next

End Sub

Private Sub FormatProjectItem(ByVal projectItem As ProjectItem)

If projectItem.Kind = Constants.vsProjectItemKindPhysicalFile Then

If projectItem.Name.LastIndexOf(".cs") = projectItem.Name.Length - 3 Then

Dim window As Window = projectItem.Open(Constants.vsViewKindCode)

window.Activate()

projectItem.Document.DTE.ExecuteCommand(
"Edit.FormatDocument")

window.Close(vsSaveChanges.vsSaveChangesYes)

End If

End If

'Be sure to format all of the ProjectItems.

If Not projectItem.ProjectItems Is Nothing Then

For i As Integer = 1 To projectItem.ProjectItems.Count

FormatProjectItem(projectItem.ProjectItems.Item(i))

Next

End If

 

'Format the SubProject if it exists.

If Not projectItem.SubProject Is Nothing Then

FormatProject(projectItem.SubProject)

End If

End Sub

The macro ended up modifying 600 files out of around 1600... not too shabby. I can only imagine what my poor wrists would have experienced had I done it manually.

Currently rated 5.0 by 4 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

visual studio, macro, vbscript

Kodefu

E-mail | Kick it! | DZone it! | del.icio.us
Permalink | Comments (5) | Post RSSRSS comment feed

XML Nugget of Joy

by chris 27. June 2007 12:22

I needed to stick a small piece of xml into a database field, sans any wordy junk that tends to inhabit xml. My requirement has length restrictions, so I wanted to keep the character count down. Basically, I needed something like this:

<candy>

<chocolate>yum</chocolate>

<caramel>creamy</caramel>

<nougat>whatisthis</nougat>

</candy>

Pretty simple, huh? My first inclination was to use XmlDocument and start adding nodes, but that tact turned out to be cumbersome and was too procedural for my taste. So, I turned to making a small data holding class so I could serialize it!

[Serializable]
[
XmlRoot("candy")]
public class
CandyData
{

string _chocolate;
string _caramel;
string _nougat;

[XmlElement("chocolate")]
public string Chocolate
{

get { return _chocolate; }
set { _chocolate = value; }

}

[XmlElement("caramel")]
public string Caramel
{

get { return _caramel; }
set { _caramel = value; }

}

[XmlElement("nougat")]
public string Nougat
{

get { return _nougat; }
set { _nougat = value; }

}

}

That's pretty straight-forward as well. The problem came when I serialized the class and look at what was being returned: declarations and namespaces. It turns out that special steps are required to strip out the xml declaration from the top, <?xml version="1.0" encoding="utf-16"?>, and the namespace, xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xmlns:xsd=http://www.w3.org/2001/XMLSchema, from the root element.

Instead of writing up a gigantic article describing every step I took to figure this out (google and msdn), how about I give out the code that does it and illustrates what's required!

public static class XmlNugget

{

/// <summary>
///
Serializes the specified obj into simple xml text.
/// </summary>
///
<param name="obj">The obj to serialize</param>
///
<returns>A simple xml nugget of joy.</returns>
public static string Serialize(Object obj)
{


XmlSerializer serializer = new XmlSerializer(obj.GetType());
StringBuilder sb = new StringBuilder();

//This will clear out default namespaces
XmlSerializerNamespaces ns = new XmlSerializerNamespaces();
ns.Add(
String.Empty, String.Empty);

//This is needed to get rid of the <?xml...>
XmlWriterSettings settings = new XmlWriterSettings();
settings.OmitXmlDeclaration = true;

XmlWriter xmlWriter = XmlTextWriter.Create(sb, settings);
serializer.Serialize(xmlWriter, obj, ns);


return sb.ToString();

}


}

This is a simple static class that takes an object and spits out xml in a string. The xml is a simple structure... no namespacing or anything unless you defined it in your class attributes. In my opinion, this helper class is preferable to typing all that junk out everytime you need to serialize an object into xml and then read it into a string.

If you're looking for a more professional name, I recommend SimpleXmlText. Unfortunately, sugar cravings do weird things to a programmer's mind. That's what I get for switching to black coffee with no sugar.

Currently rated 5.0 by 2 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

xml, serialization, c#

Kodefu

E-mail | Kick it! | DZone it! | del.icio.us
Permalink | Comments (2) | Post RSSRSS comment feed

Powered by BlogEngine.NET 1.3.1.0
Theme by Mads Kristensen

About the author

Chris Eargle Chris Eargle
Enterprise .NET developer in Columbia, SC.

E-mail me Send mail

Calendar

<<  August 2008  >>
MoTuWeThFrSaSu
28293031123
45678910
11121314151617
18192021222324
25262728293031
1234567

View posts in large calendar

Pages

    Recent posts

    • Create Vista Icons in VS 2008Comments: 0Rating: 0 / 0
    • String to StreamComments: 0Rating: 0 / 0
    • Hung Database RestoreComments: 0Rating: 0 / 0
    • MSI Compilation ErrorComments: 0Rating: 0 / 0
    • Moving Parts and TimeoutsComments: 0Rating: 0 / 0
    • C# 3.0 PresentationComments: 1Rating: 0 / 0
    • Augusta Meeting TonightComments: 0Rating: 5 / 3
    • WCF 3.5 Security GuidelinesComments: 0Rating: 0 / 0
    • .NET 3.5 Enhancements Training KitComments: 0Rating: 0 / 0
    • Sessions GaloreComments: 1Rating: 0 / 0

    Recent comments

    • C# 3.0 Presentation (1)
      vijay wrote: Good post Thanks, Vijay [More]
    • Format Solution (4)
      Joe wrote: I added a couple of lines to FormatProjectItem() t… [More]
    • Sessions Galore (1)
      Lou wrote: I'll have to get you down here soon - I'll e-mail … [More]
    • Redeemed (3)
      Fred Beiderbecke wrote: It wasn't you, it was some of the others in the ro… [More]
    • South Florida Code Camp (1)
      Jason Meridth wrote: You've mentioned the only latest difference betwee… [More]
    • Redeemed (3)
      Chris Eargle wrote: Hmm, the only thing derisive I remember saying abo… [More]
    • Redeemed (3)
      Fred Beiderbecke wrote: I was in the afternoon session and enjoyed it (exc… [More]
    • Format Solution (4)
      Tony Evans wrote: Just what I was looking for. Thanks! :o) [More]
    • XML Nugget of Joy (2)
      Chris Eargle wrote: How do you retrieve the description, and in what c… [More]
    • XML Nugget of Joy (2)
      Wesley Wilson wrote: That's pretty neat. I've just started using attrib… [More]

    Archive

    • 2008
      • August (3)
      • July (1)
      • June (1)
      • April (4)
      • March (1)
      • February (4)
      • January (5)
    • 2007
      • December (5)
      • November (1)
      • October (6)
      • September (3)
      • August (1)
      • June (1)

    Authors

    • RSS feed for chrischris (36)

    Tags

    • activex
    • addin
    • ado.net data services
    • ajax
    • architecture
    • astoria
    • beta
    • c#
    • code camp
    • com
    • consolas
    • continuous integration
    • ctp
    • database
    • deployment
    • design
    • download
    • ebook
    • entity
    • expression blend
    • font
    • framework
    • gadget
    • grid
    • guidelines
    • icon
    • lamdba
    • linq
    • macro
    • msbuild
    • msi
    • mvc
    • powertoy
    • preview
    • ray ozzie
    • regasm
    • security
    • serialization
    • silverlight
    • source code
    • sql server
    • starter kit
    • stream
    • string
    • trial
    • usability
    • ux
    • vbscript
    • vista
    • visual studio
    • vs2008
    • wcf
    • web
    • winforms
    • wpf
    • xml

    Categories

    • RSS feed for Bleeding EdgeBleeding Edge (3)
    • RSS feed for GeneralGeneral (1)
    • RSS feed for KodefuKodefu (8)
    • RSS feed for Path NotesPath Notes (6)
    • RSS feed for PresentationPresentation (2)
    • RSS feed for TechniquesTechniques (2)
    • RSS feed for TrainingTraining (5)
    • RSS feed for WeaponsWeapons (4)
    • RSS feed for ZenZen (4)

    Archive

    Blogroll

    • RSS feed for Structure Too BigStructure Too Big
      • MSDN Event Thursday in...
      • WorldMaps Update
      • ASP.NET University!
    • RSS feed for Chris CraftChris Craft
      • Pimp My Phone – D...
      • Pimp My Phone – D...
      • Pimp My Phone – D...
    Download OPML file OPML

    Disclaimer

    The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

    © Copyright 2008

    Sign in