private void ConvertFileReferencesToComReferenceInfo(List<ComReferenceInfo> projectRefs, ITaskItem[] tlbFiles)
 {
     int num = (tlbFiles == null) ? 0 : tlbFiles.GetLength(0);
     for (int i = 0; i < num; i++)
     {
         string itemSpec = tlbFiles[i].ItemSpec;
         if (!Path.IsPathRooted(itemSpec))
         {
             itemSpec = Path.Combine(Directory.GetCurrentDirectory(), itemSpec);
         }
         ComReferenceInfo item = new ComReferenceInfo();
         try
         {
             if (item.InitializeWithPath(base.Log, itemSpec, tlbFiles[i], this.TargetProcessorArchitecture))
             {
                 projectRefs.Add(item);
             }
             else
             {
                 item.ReleaseTypeLibPtr();
             }
         }
         catch (COMException exception)
         {
             base.Log.LogWarningWithCodeFromResources("ResolveComReference.CannotLoadTypeLibItemSpec", new object[] { tlbFiles[i].ItemSpec, exception.Message });
             item.ReleaseTypeLibPtr();
         }
     }
 }
예제 #2
0
        /*
         * Method:  ConvertFileReferencesToComReferenceInfo
         * 
         * Helper method. Converts TypeLibFiles references to ComReferenceInfo objects
         * This method cannot fail, since we want to proceed with the task even if some references won't load.
         */
        private void ConvertFileReferencesToComReferenceInfo(List<ComReferenceInfo> projectRefs, ITaskItem[] tlbFiles)
        {
            int tlbFilesLength = (tlbFiles == null) ? 0 : tlbFiles.GetLength(0);

            for (int i = 0; i < tlbFilesLength; i++)
            {
                string refPath = tlbFiles[i].ItemSpec;

                if (!Path.IsPathRooted(refPath))
                    refPath = Path.Combine(Directory.GetCurrentDirectory(), refPath);

                ComReferenceInfo projectRefInfo = new ComReferenceInfo();

                try
                {
                    if (projectRefInfo.InitializeWithPath(Log, Silent, refPath, tlbFiles[i], this.TargetProcessorArchitecture))
                    {
                        projectRefs.Add(projectRefInfo);
                    }
                    else
                    {
                        projectRefInfo.ReleaseTypeLibPtr();
                    }
                }
                catch (COMException ex)
                {
                    if (!Silent)
                    {
                        Log.LogWarningWithCodeFromResources("ResolveComReference.CannotLoadTypeLibItemSpec", tlbFiles[i].ItemSpec, ex.Message);
                    }

                    projectRefInfo.ReleaseTypeLibPtr();
                    // we don't want to fail the task if one of the references is not registered, so just continue
                }
            }
        }
 private void ConvertAttrReferencesToComReferenceInfo(List<ComReferenceInfo> projectRefs, ITaskItem[] typeLibAttrs)
 {
     int num = (typeLibAttrs == null) ? 0 : typeLibAttrs.GetLength(0);
     for (int i = 0; i < num; i++)
     {
         ComReferenceInfo item = new ComReferenceInfo();
         try
         {
             if (item.InitializeWithTypeLibAttrs(base.Log, TaskItemToTypeLibAttr(typeLibAttrs[i]), typeLibAttrs[i], this.TargetProcessorArchitecture))
             {
                 projectRefs.Add(item);
             }
             else
             {
                 item.ReleaseTypeLibPtr();
             }
         }
         catch (COMException exception)
         {
             base.Log.LogWarningWithCodeFromResources("ResolveComReference.CannotLoadTypeLibItemSpec", new object[] { typeLibAttrs[i].ItemSpec, exception.Message });
             item.ReleaseTypeLibPtr();
         }
     }
 }
예제 #4
0
        /*
         * Method:  ConvertAttrReferencesToComReferenceInfo
         * 
         * Helper method. Converts TypeLibAttr references to ComReferenceInfo objects.
         * This method cannot fail, since we want to proceed with the task even if some references won't load.
         */
        private void ConvertAttrReferencesToComReferenceInfo(List<ComReferenceInfo> projectRefs, ITaskItem[] typeLibAttrs)
        {
            int typeLibAttrsLength = (typeLibAttrs == null) ? 0 : typeLibAttrs.GetLength(0);

            for (int i = 0; i < typeLibAttrsLength; i++)
            {
                ComReferenceInfo projectRefInfo = new ComReferenceInfo();

                try
                {
                    if (projectRefInfo.InitializeWithTypeLibAttrs(Log, Silent, TaskItemToTypeLibAttr(typeLibAttrs[i]), typeLibAttrs[i], this.TargetProcessorArchitecture))
                    {
                        projectRefs.Add(projectRefInfo);
                    }
                    else
                    {
                        projectRefInfo.ReleaseTypeLibPtr();
                    }
                }
                catch (COMException ex)
                {
                    if (!Silent)
                    {
                        Log.LogWarningWithCodeFromResources("ResolveComReference.CannotLoadTypeLibItemSpec", typeLibAttrs[i].ItemSpec, ex.Message);
                    }

                    projectRefInfo.ReleaseTypeLibPtr();
                    // we don't want to fail the task if one of the references is not registered, so just continue
                }
            }
        }