diff --git a/src/Cms/Transform.cs b/src/Cms/Transform.cs
index 22beb5e..a9c45f9 100644
--- a/src/Cms/Transform.cs
+++ b/src/Cms/Transform.cs
@@ -10,6 +10,7 @@
 using System;
 using System.IO;
 using System.Collections;
+using System.Collections.Generic;
 using System.Runtime.InteropServices;
 using System.Reflection;
 using System.Runtime.Serialization;
@@ -31,10 +32,12 @@ namespace Cms {
 			if (profiles == null)
 				throw new ArgumentNullException ("profiles");
 
-			HandleRef [] handles = new HandleRef [profiles.Length];
+			var good_handles = new List <HandleRef> ();
 			for (int i = 0; i < profiles.Length; i++) {
-				handles [i] = profiles [i].Handle;
+				if (profiles [i] != null)
+					good_handles.Add (profiles [i].Handle);
 			}
+			HandleRef [] handles = good_handles.ToArray ();
 			
 			this.handle = new HandleRef (this, NativeMethods.CmsCreateMultiprofileTransform (handles, handles.Length, 
 											   input_format,
