/// <summary>
        /// Assembly is Uploaded if it is database.
        /// We dont do Smart updates
        /// </summary>
        /// <param name="org"></param>
        /// <param name="pathToAssembly"></param>
        /// <param name="assembly"></param>
        public static void UpdateAssembly(CrmOrganization org, string pathToAssembly, CrmPluginAssembly assembly,
                                          params PluginType[] type)
        {
            if (org == null)
            {
                throw new ArgumentNullException("org");
            }
            else if (assembly == null)
            {
                throw new ArgumentNullException("assembly");
            }

            PluginAssembly ptl = (PluginAssembly)assembly.GenerateCrmEntities()[PluginAssembly.EntityLogicalName];

            //If the assembly path is not set, then the content does not need to be updated
            if (!string.IsNullOrEmpty(pathToAssembly) &&
                assembly.SourceType == CrmAssemblySourceType.Database)
            {
                ptl.Content = Convert.ToBase64String(File.ReadAllBytes(pathToAssembly));
            }

            if (null != type && 0 != type.Length)
            {
                ptl.pluginassembly_plugintype = type;
            }

            org.OrganizationService.Update(ptl);
            OrganizationHelper.RefreshAssembly(org, assembly);
        }
        public static Guid RegisterAssembly(CrmOrganization org, string pathToAssembly, CrmPluginAssembly assembly)
        {
            if (org == null)
            {
                throw new ArgumentNullException("org");
            }
            else if (assembly == null)
            {
                throw new ArgumentNullException("assembly");
            }
            else if (assembly.SourceType == CrmAssemblySourceType.Database && pathToAssembly == null)
            {
                throw new ArgumentNullException("pathToAssembly", "Cannot be null when SourceType is Database");
            }

            PluginAssembly ptl = (PluginAssembly)assembly.GenerateCrmEntities()[PluginAssembly.EntityLogicalName];

            if (assembly.SourceType == CrmAssemblySourceType.Database)
            {
                ptl.Content = Convert.ToBase64String(File.ReadAllBytes(pathToAssembly));
            }

            return(org.OrganizationService.Create(ptl));
        }