Signing a (3rd Party) complied .NET assembly

You may have referenced an assembly from your strongly named project and noticed an “Assembly generation failed — Referenced assembly does not have a strong name” exception. Or “Could not load file or assembly or one of its dependencies. A strongly-named assembly is required.” While working with an open-source component, I found that I was in this situation. In that case, I asked the primary developer if the assembly could be strongly named and he agree to do so. You may not have been so lucky.

  1. Start up the Visual Studio Command Prompt
  2. Create a .snk key file.
  3. Dis-assemble the assembly
  4. Re-Assemble using your strong-name key

You can use the following commands.

cd c:\workingdir\

sn -k sgKey.snk

 

You will need to replace originalAssembly below with the name of your assembly and drop a copy of it into c:\workingdir\. Use this pair of commands for a dll.

ildasm originalAssembly.dll /out:temp.il

ilasm temp.il /res:temp.res /dll /key:sgKey.snk /out:originalAssemblySN.dll

 

Use this pair of commands for an exe.

ildasm originalAssembly.exe /out:temp.il

ilasm temp.il /res:temp.res /key:sgKey.snk /out:originalAssemblySN.exe

 

That’s how you assign a strong name to (how to sign) an unsigned assembly!

What is the ComputerEase Accounting Database Structure?

There is a utility included with the ComputerEase construction software that will print out portions or all of the database table structure. This may be particularly useful when trying to interoperate with the data.

Open a command prompt window at the directory where your ComputerEase software resides.

Use the following command to redirect input to a file and “print out” all database tables.

printdic > schema.txt

You may also view a single table at a time, by specifying it’s name.

printdic jcjob

Here is a sample screenshot of the results.

image

Get Rid of Visual Studio 2008 Memory Errors

I began to see OutOfMemoryException and “Not enough storage is available to process this command” while running Visual Studio 2008 on Windows 7. It’s time to flip the 3GB switch. Here’s how it’s done.

Open a command prompt window running as Administrator. Then execute the following commands in order. Finally, restart windows.

image

BCDEDIT /Set IncreaseUserVa 3072

cd C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\

editbin /LARGEADDRESSAWARE devenv.exe

copy devenv.exe devenv.bak

Why doesn’t Gmail display CSS in email

You’ve worked hard to make sure that your electronic newsletter is coded in pretty HTML and CSS. Then you open it up in a web-based email reader and the CSS is gone!

Gmail ripped out the style tag. While this makes some sense from a security standpoint — we wouldn’t want some sneak CSS in a phishy email messing with your email reader — Google could go further and rewrite the CSS to make it inline, stripping out the CSS class names as it went. Of course, that increases the size of the message as demonstrated.

Many webmail clients support style tag based CSS. Perhaps this is why Gmail is still in beta. Email readers need standards as much as web browsers! Fortunately, there is a guide online that outlines what CSS is support by different email clients.

It turns out that enough of our users use online webmail readers and wanted pretty emails that we’re accommodating gmail and throwing out the extra bits to make it happen. I noticed that none of my favorite refactoring tools helped in the process.

Long live the user experience!

Does ASP.NET really do that?

A coworker told me that he noticed slow performance on our website when folders were deleted in the solution. We do not usually need to delete folders during production use, but he wanted me to look into it.

Sure enough, I was able to reproduce this behavior, furthermore I found others that had experienced the same problem, and a workaround.

void Application_Start(object sender, EventArgs e)
{
    // prevent file changes monitoring on subdirectories
    PropertyInfo p = typeof(System.Web.HttpRuntime).GetProperty(
        "FileChangesMonitor",
        BindingFlags.NonPublic | 
        BindingFlags.Public | 
        BindingFlags.Static);

    FieldInfo f = p.GetValue(null, null).GetType().GetField(
        "_dirMonSubdirs",
        BindingFlags.Instance |
        BindingFlags.NonPublic |
        BindingFlags.IgnoreCase);

    object monitor = f.GetValue(p.GetValue(null, null));
    MethodInfo m = monitor.GetType().GetMethod(
        "StopMonitoring",
        BindingFlags.Instance | BindingFlags.NonPublic);

    m.Invoke(monitor, new object[] { }); 
}

Cross-database calls with LINQ to SQL

Cross database queries are often one of those facts of development. LINQ to SQL offers several advantages that you might want in your project. Unfortunately, a Query cannot contain references to items defined on different data contexts.

Here’s one solution.

Modify the Source attribute of the tables that resides in a database other than the one mentioned in your connection string. For example, change "dbo.tbName" to "otherDataBaseName.dbo.tbName".

Keep in mind the security context of your connection; you will need a single user that can connect to both databases (the databases will also need to reside on the same server).

Tip: I used a second dbml file for adding the tables that are hosted in the second database. Then I copied the dbml over to the original dbml file and modified the Source attribute.

Excited about Windows 7

I’ve been rather excited about the release of Windows 7 RC (release candidate). I have been running the beta for some time now and have found that I appreciate several of the features in this new release of my operating system.

  • View windows side-by-side by dragging them
  • Maximize windows by dragging them to the top of the screen
  • Enhanced search (at Start button)
  • Quicker boot, fast resume from standby
  • Opening files faster with just two clicks and no desktop clutter (using jump lists)
  • Watching video across a remote desktop session

A feature I wish was available in all versions of Windows: Problem Steps Recorder.

If you want to see some of these in action, Microsoft has released a Windows 7snack.

A Tribute to Eric

One of our coworkers, our logistics coordinator, is now leaving us. He has chosen to move to the west coast where he will continue a slightly different line of work. That coworker, Eric, has been an integral part of the work I do over the past year. As such, I thought it would be fitting to make a few remarks about his contribution to the software we use, and describe how it has evolved over time, largely in part due to his direction and enthusiasm.

Akin to other small businesses, employees at Dome Technology often find themselves filling several roles. Eric not only ensured that equipment and supplies were available at our project sites around the world, he also took care to make sure the equipment was maintained, and licensed and registered as necessary.

Eric was one of the brave individuals that didn’t fear change. He was always open to improving the process and methods we used and automating what we could, given our resource constraints. His great attitude encouraged us to look at removing some of the burden from his work by creating an electronic system that would keep track of equipment.

Knowing where our equipment was located became the center of a slowly growing application that now has six main modules and is used by over half of our office employees. Perhaps none of these modules was created due to some business requirement, but rather because Eric’s example and use of this software lead others to understand the value that such software would add to their workflow.

I don’t think Eric has yet recognized that nearly everything of value I have been able to create and see come to fruition has been related to his original willingness to innovate and change and his understanding of the opportunities provided by bespoke software development.