Skip to main content

Visual Studio Says: "Failed to create component"

· 2 min read

Problem

"Failed to create component" error pops up when dragging a custom Windows Forms control from the Toolbox onto a form. Offending line: foreach (Attribute att in Assembly.GetEntryAssembly().GetCustomAttributes(true)).

Background

I have started building a custom DLL containing items for re-use between different Windows Forms projects. An obvious candidate is an About window. I created this as a custom control in the DLL project; the control contains a textbox, which I want to fill with the application name, the version, copyright information, and company name. All of this is to come from the AssemblyInfo.cs file, using System.Reflection where necessary:

Rethrowing Exceptions Is a Dangerous Business

· 3 min read

Problem

in Visual Studio's debugger, you've landed on an Exception statement. You look at the stack trace but it just points back to a custom exception class you've created. But you know that code is good, it can't be throwing the error. What's going on here?

Solution

this is an easy mistake to make. I've run it across it in code from a number of people, and recall making the mistake myself at one point. The problem is most likely due to nested throws to a new custom exception.

Collection Performance Comparisons

· 2 min read

This is not part of my series on performance tuning a specific app.

Problem

I have a Registry class in which I want to place a generic collection of objects. In this way I can add new items to the registry on the fly (i.e. from a user application), without having to recompile the library containing the the class. What is my best option, in terms of performance, for a .Net 2.0 collection to hold my mixed-bag of objects? I'll be referring to these with a string name.

Performance #3: CLR Profiler

· 3 min read

This article is part of the series An Exercise in Performance Tuning in C#.Net.

Where else could I improve performance? I thought I should inspect the memory usage and garbage collection. For that I found a great little tool from Microsoft, the CLR Profiler, which I found through the MSDN Patterns & Practices series of guides on application performance and scalability. The specific article that I found most helpful was How To: Use CLR Profiler.

Replacing Ad Hoc Query Text When Fields Change

· 5 min read

Situation: We have a stored procedure running a query whose WHERE clause is given as a parameter. No, that's not the problem in and of itself, at least not today. (Treat this as a non-negotiable requirement for now). Within that WHERE clause there might be a query against a field, call it myField. This field is a varchar and wildcards are not used. Platform: SQL Server 2005.

Problem

myField has been changed to a varbinary field and holds an encrypted value — thus can no longer query directly against it. How do we make this work?

Granting Execute Permission to All Stored Procedures

· One min read

Problem

You've transferred or run a bunch of stored procedure scripts, but you can't execute them. Reason - execute permission denied. You forgot to put a grant statement in your script.

Solution

The trivial solution is, of course, GRANT EXECUTE ON {your proc name} TO PUBLIC. Slightly less trivial is to grant to a specific role, but most people needing this tip will only be using PUBLIC.

Wouldn't it be great to automate this for all stored procedures in the database? Well, here you go:

safnet logo