| | Sun | Mon | Tue | Wed | Thu | Fri | Sat |
|---|
| 24 | 25 | 26 | 27 | 28 | 29 | 1 | | 2 | 3 | 4 | 5 | 6 | 7 | 8 | | 9 | 10 | 11 | 12 | 13 | 14 | 15 | | 16 | 17 | 18 | 19 | 20 | 21 | 22 | | 23 | 24 | 25 | 26 | 27 | 28 | 29 | | 30 | 31 | 1 | 2 | 3 | 4 | 5 |
Subscribe to this feed:
|
|
Archives:
| May, 2010 (1) |
| March, 2010 (1) |
| November, 2009 (1) |
| September, 2009 (1) |
| July, 2009 (2) |
| June, 2009 (1) |
| May, 2009 (1) |
| March, 2009 (5) |
| February, 2009 (3) |
| July, 2008 (1) |
| June, 2008 (2) |
| May, 2008 (1) |
| April, 2008 (2) |
| March, 2008 (4) |
| February, 2008 (4) |
| December, 2007 (2) |
| October, 2007 (2) |
| September, 2007 (1) |
| June, 2007 (1) |
| May, 2007 (4) |
| April, 2007 (4) |
| March, 2007 (2) |
| February, 2007 (4) |
| January, 2007 (3) |
| December, 2006 (1) |
| November, 2006 (4) |
| October, 2006 (7) |
| September, 2006 (2) |
| August, 2006 (14) |
| July, 2006 (9) |
|
We've been having some weirdness going on with our source control. Nothing major- (Note to our clients: your code is safe and backed up daily!) - but little things like files getting out of sync, or appearing checked in in the IDE, but not in the source control server. While searching about it, I ran across this definitive guide to source control by none less than Mr. Source Control himself, Eric Sink- founder of SourceGear. This mini e-book is very well-written and covers a broad spectrum of source control concepts and tools - not just Vault. In addition to explaining the concepts in laymen's terms, he peppers best practice side-bars through out the text, distilling the concepts into concrete guidance developers can use. It's old - started in Aug 2004- so I'm surprised I'm just now coming across this, but it's definitely a must-read for any developer working in a team > 1.
I've been experimenting with the idea of using System.Reflection.Emit to generate code from interfaces. If you're not familiar with this namespace, it contains classes to generate compiled assemblies programmatically. Regex uses this when compiling a regular expression for faster execution. Instead of parsing the expression each time, it generates on-the-fly a class that can be used to execute the expression. This namespace is also used by Mock Type frameworks such as RhinoMocks and TypeMock. Given a base class or interface, these generate on-the-fly a class that can mimic the base enough to use when unit testing. I'm sure there are other places this is used, but suffice it to say this is one of those obscure corners of the framework that us Morts rarely dig into. So it's not surprising that I would run into an obscure error that stumped even Google. I religiously studied the MSDN examples and wrote code to let me do something like this: ICustomer concreteType = CodeGenerator<ICustomer>.GetInstance(); You can see how freaking awesome this could be for component development- I get, at runtime, a class that implements my interface, but I don't have to wire up goo like INotifyPropertyChanged, IDataError, property getter/setters, etc. Depending on how my tinkering goes, more on the awesomeness later. The error I was getting whenever I called typeBuilder.CreateType() was: System.TypeLoadException: Method 'get_Id' in type 'Customer' from assembly 'TypeAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' does not have an implementation Except I WAS implementing 'get_Id'. I copied the code to do it straight from MSDN! See: MethodAttributes getSetAttributes = MethodAttributes.Public | MethodAttributes.SpecialName | MethodAttributes.HideBySig; var getMethodBuilder = typeBuilder.DefineMethod("get_" + propertyOnInterface.Name, getSetAttributes, propertyOnInterface.PropertyType, Type.EmptyTypes); ILGenerator getMethodIl = getMethodBuilder.GetILGenerator(); getMethodIl.Emit(OpCodes.Ldarg_0); getMethodIl.Emit(OpCodes.Ldfld, fieldBuilder); getMethodIl.Emit(OpCodes.Ret); propBuilder.SetGetMethod(getMethodBuilder); Much googling turned up only a few unrelated posts. After testing, I discovered that removing a call to 'AddInterfaceImplementation' fixed the issue- though the resulting class no longer implemented my interface. Clearly the interface was generating some sort of code. Some more digging, and I figured out the solution: MethodAttributes getSetAttributes = MethodAttributes.Public | MethodAttributes.SpecialName | MethodAttributes.HideBySig;| MethodAttributes.Virtual; I could be flawed in my understanding here, but apparently, when adding an interface, .NET treats property get and set accessors sort of like abstract methods. The code I was generating did implement 'get_Id', but did not mark it as overriding the interface's definition. So, when creating the type, there was the interfaces' unfinished implementation of 'get_Id', and my completely unrelated 'get_Id'. So anyway, hopefully this post will make it into Google and help some other poor guy who, late one night, finds themselves turning over parts of the framework better left alone.
Here's a fun Alt-Tab Shortcut that lets you switch apps without leaving the comfort of your mouse. Just download, place in Startup, and run. When it's running, you can switch apps by holding down the left mouse button and clicking the right. Like most productivity apps, I may find myself forgetting it's there and not using it after the novelty wears off, but I guess we'll see. Incidentally, the standalone exe is a feature of AutoHotKeys, which is one of those said productivity apps that I forget about and rarely use. The idea is pretty neat though. It's a little scripting language for automating those little repetitive tasks that we all hate. The end result is apparently a standalone exe that "just works", no installer required.
One of the challenges of being a contract software developer is that we often work remotely on a clients' network via VPN. Each client has their own VPN client, Source Control, and development environments. In many cases, development platforms just aren't made with this in mind. It's only as of VS 2005 that you can even switch Source Control Providers easily! If you've ever had to connect to Microsoft SourceSafe over VPN, you know it's still not designed with remote work in mind. It relies on a network file share, which can be problematic over VPN. It does ship with a WebService based solution, but this may not be feasible for the client to install in all cases. The Problem When connecting over VPN, the main problem is that there is no option to specify the network user to connect with. For example, you may log in to the clients' VPN, but still attempt to access resources using your machine's local account. When doing things like mapping drives, it's easy to supply an alternate username and password. However, with SourceSafe, there is no option to supply network credentials when connecting (which are totally different from the SourceSafe credentials). The Solution Enter the Windows runas command. This command lets you run any application as though it were a different user. In this case, you want to run Visual Studio as though you were that network user. To set this up: - Create an empty text file named "RunVisualStudioAs[DomainUserName].bat"
- Edit and Add the following:
- runas /netonly /user:[Domain]\[User] "C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe"
- Save.
Then, when working on the project, just launch VS using the batch file. You will be prompted for a password each time, since runas does not allow entering a password in the commandline for obvious security reasons. But there are 3rd party runas replacements which can help you get around this. One other word of caution: Due to the chatty nature of Windows file sharing, this will still be very slow over a remote connection. Turning off Anti-Virus helps a little, and there are some additional speed tips here. It's definitely not the ideal solution, but it can be done!
For one of our clients, I've been working on converting printed forms into web forms, and in the process have been dealing with a lot of tables that need to fit within a fixed width. These tables are in a FormView in a User Control, which are then placed on webpages as needed. I was finding that Visual Studio 2008's design mode was happy enough to accept my fixed-width columns and tables settings in my CSS stylesheet when working on the User Control, but once that User Control is placed on an actual page the fixed-width settings are no longer respected in both design mode and in debug mode displayed through a browser. What to do? After much frustration I found the embarrasingly simple answer: I wasn't putting "px" at the end of pixel measurements for table/column widths. For whatever reason the Visual Studio 2008 FormView designer was content without the "px" but nothing else was. In my rush to get things working I was leaving off the "px" figuring that I could go back later and add them on after the fact. So lesson learned: be standards compliant, even if your development tool of choice lets you get away with not being standards compliant.
Still on the topic of fixed-width tables and columns, have you ever wanted to figure out exactly how many pixels wide/tall something is on a webpage, be it a table row, table column, header graphic, etc.? Enter Pixel Ruler--a free app that displays a rotatable ruler on your screen and even tracks your mouse cursor and keeps a running measurement of how many pixels away you are from the zero mark on the ruler (in one dimension of course--it doesn't do diagonal measurements). This app will save me countless hours of eyeballing and hoping for the best, instead providing me with precise measurements to the pixel.
One of the fun things about working at LifeCycle is the constant exposure to a wide range of technologies. We have clients in just about every vertical market you can name, so we see a variety of "cool stuff" on a regular basis. For example, one of our clients, Global Security Systems, offers an emergency communications solution called ALERT FM.
ALERT FM is a product created out of necessity -- after Hurricane Katrina hit in 2005, the founders of Global Security Systems knew there had to be a better way to get emergency information out to people. In many areas, the communications infrastructure was partially or completely destroyed; however, even in the hardest-hit areas, most people could still get information through their FM radio stations. Building on this, the company created GSSNet, a network of existing FM radio stations that could be used to transmit data over the FM airwaves.
Global Security Systems now offers ALERT FM, a suite of tools for sending and receiving messages over the GSSNet backbone. For receiving alert messages, the company currently offers an inexpensive battery-powered receiver, a USB stick with a built-in ALERT FM receiver and a wall-mounted device that can be used in schools and businesses. Out of the box, users can receive weather alerts and other important information for their area. For sending alert messages, the company offers a personalized web portal to state/federal/local government and businesses in the private sector. Government users, like state and county emergency agencies, can generate their own alert messages to be broadcast in their area (e.g. notifying people to stay away from an area due to a hazardous chemical spill). Companies in the private sector can also use the portal to send out their own "private" alerts, making ALERT FM a good solution for companies concerned with alerting their employees in the event of a disaster.
If your company is formulating a disaster recovery or business continuity plan for 2008 and beyond, you should get in touch with ALERT FM -- it's a very effective way to quickly broadcast information to your employees when other means of communication aren't available. ALERT FM is one of the coolest things we've had an opportunity to be a part of in 2007.
I recently had an ASP.NET project with the following requirements: - Build 2 CSV files from SQL Server data based on parameters specified by the user - Build a ZIP archive containing these files and allow the user to download
It's been a while since I'd worked with ZIP archives in ASP.NET, so I thought I'd share the solution. One of the best libraries I've found for creating a wide range of compressed files is SharpZipLib. There are numerous examples of compressing files located in the file system with SharpZipLib, but this project required me to build the archive in-memory in order to avoid unnecessary disk I/O. Here's how it's done:
string summaryResult = BuildOrderSummary();
string detailResult = BuildOrderDetail();
string fileName = "Orders.zip";
Encoding ascii = Encoding.ASCII;
MemoryStream memOutput = new MemoryStream();
ZipOutputStream zipOutput = new ZipOutputStream(memOutput);
zipOutput.SetLevel(5);
//convert the strings into byte arrays
byte[] headerFile = ascii.GetBytes(summaryResult);
byte[] detailFile = ascii.GetBytes(detailResult);
ZipEntry summaryEntry = new ZipEntry("OrderSummary.csv");
ZipEntry detailEntry = new ZipEntry("OrderDetail.csv");
//add the summary file to the ZIP archive
summaryEntry.Size = headerFile.Length;
zipOutput.PutNextEntry(summaryEntry);
zipOutput.Write(headerFile, 0, headerFile.Length);
//add the detail file to the ZIP archive
detailEntry.Size = detailFile.Length;
zipOutput.PutNextEntry(detailEntry);
zipOutput.Write(detailFile, 0, detailFile.Length);
//clean up the ZIP stream
zipOutput.Finish();
zipOutput.Close();
//clean up the memory stream
memOutput.Close();
//send the ZIP file back to the user
Response.ContentType = "application/zip";
Response.AddHeader("content-disposition", "attachment; filename=" + fileName);
Response.BinaryWrite(memOutput.ToArray());
Response.Flush();
Response.End();
We recently ran into an issue concernig an Automatic Security update for Windows 2003 and WSS 3.0. The customer's SharePoint site became inoperative and displayed a 'Cannot connect to the configuration database' error. The server Application Log showed a Windows SharePoint Services error of 'Unkown SQL Exception 33002' - 'Access to module dbo.proc_getObjectsByClass is blocked because the signature is not valid.' Turns out that this was caused by a security update for Windows SharePoint 3.0 reference KB934525. If this patch is applied you have to run psconfig -cmd upgrade -inplace b2b. This utility can found under Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\Bin . Please reference KB934525.
Ron
One technique we've started using is automating our apps' configuration using Pre-Build Events and Build Configurations in Visual Studio. It takes a little more work to set up, but once you do, publishing test and production apps is much easier. It also helps the developer to think not just about a "works on my machine" app, but an app that works on any number of scenarios. Without this approach, the developer still has to keep up with multiple config files, but typically does so in their head. Scott Guthrie has a great post showing how all this is done. However, a few tips will help you fine tune your automation, so that development is even more painless:
- Decide the different scenarios your app will run in. In our case there are typically 3:
- Local - App is being developed and running on the developers' PC
- Staging - App is being tested in a copy of the production environment
- Production - App is "live".
- Create a folder named Configuration.
- Create a .config file for each scenario above.
- Name the .config file scenario.web.config or scenario.app.config (ie local.web.config). Using this approach over Scott's means you still get intellisense in the .config files!
- If you have an existing .config file, just copy it to the Configuration folder and rename it as above. Remember that after this is set up, the "real" .config file will be overwritten. If you put blank .config files in Configuration, you'll loose the "real" configuration file.
- Create Build Configurations in Configuration Manager for each scenario above.
- In each configuration, add the following Pre-Build event
-
IF EXIST "$(ProjectDir)Configuration\$(ConfigurationName).web.config" xcopy "$(ProjectDir)Configuration\$(ConfigurationName).web.config" "$(ProjectDir)\web.config" /Y /R
-
This script accomodates the naming schema above, and works with source control by overwritting the read-only .config file. Note if your project is a windows forms, console, or class library app, change "web.config" to "app.config"
And that's it - before each build, the appropriate config file will be copied over and used. Note that you'll never want to change the .config file in your project's root, as it will be overwritten. Instead, whenever you need to change configuration, decide how the change will affect each scenario, and change each .config in your Configuration folder.
|