locked
VCProject AddFile RRS feed

  • Question

  • Hi,

    I getting this exception in Visual Studio 2012 when calling AddFile on a VCProject

    Microsoft.VisualStudio.Project.ProjectException: Could not find project item with item type 'ClCompile' and include value 'generated\New2.cpp'.
       at Microsoft.VisualStudio.Project.Utilities.ProjectErrorUtilities.ThrowProjectExceptionHelper(Exception innerException, String unformattedMessage, Object[] args)
       at Microsoft.VisualStudio.Project.Utilities.ProjectErrorUtilities.ThrowProjectException(String message, Object arg0, Object arg1)
       at Microsoft.VisualStudio.Project.Properties.ItemProperties.<GetEvaluatedProjectItem>b__a(IDirectReadAccess access)
       at Microsoft.VisualStudio.Project.Utilities.CommonProjectSystemTools.<>c__DisplayClass43`1.<Read>b__42(IDirectReadAccess directAccess)
       at Microsoft.VisualStudio.Project.DirectAccessService.AccessProject[T](Action`1 action, T directAccess, CancellationToken token, LockStats stats)
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
       at Microsoft.VisualStudio.Project.Utilities.CommonProjectSystemTools.Rethrow(Exception ex)
       at Microsoft.VisualStudio.Project.DirectAccessServiceLegacyThreading.MarshalToLockingThread[T](Action`1 action, T directAccess, CancellationToken token)
       at Microsoft.VisualStudio.Project.DirectAccessService.UpgradeableRead(Action`1 action, ProjectAccess flags, CancellationToken token)
       at Microsoft.VisualStudio.Project.DirectAccessServiceLegacyThreading.UpgradeableRead(Action`1 action, ProjectAccess flags, CancellationToken token)
       at Microsoft.VisualStudio.Project.DirectAccessServiceLegacyThreading.Read(Action`1 action, ProjectAccess flags, CancellationToken token)
       at Microsoft.VisualStudio.Project.Utilities.CommonProjectSystemTools.Read[T](IDirectAccessService directAccessService, Func`2 action)
       at Microsoft.VisualStudio.Project.Properties.ItemProperties.GetEvaluatedProjectItem()
       at Microsoft.VisualStudio.Project.ConfiguredProjectCache`1.UpdateValueProjectAccessHelper(Project proj, Boolean proactive)
       at Microsoft.VisualStudio.Project.ConfiguredProjectCache`1.UpdateValueProjectAccessNotProactiveHelper(Project proj)
       at Microsoft.VisualStudio.Project.Utilities.CommonProjectSystemTools.<>c__DisplayClass55.<Read>b__54(IDirectReadAccess directAccess)
       at Microsoft.VisualStudio.Project.DirectAccessService.AccessProject[T](Action`1 action, T directAccess, CancellationToken token, LockStats stats)
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
       at Microsoft.VisualStudio.Project.Utilities.CommonProjectSystemTools.Rethrow(Exception ex)
       at Microsoft.VisualStudio.Project.DirectAccessServiceLegacyThreading.MarshalToLockingThread[T](Action`1 action, T directAccess, CancellationToken token)
       at Microsoft.VisualStudio.Project.DirectAccessService.UpgradeableRead(Action`1 action, ProjectAccess flags, CancellationToken token)
       at Microsoft.VisualStudio.Project.DirectAccessServiceLegacyThreading.UpgradeableRead(Action`1 action, ProjectAccess flags, CancellationToken token)
       at Microsoft.VisualStudio.Project.DirectAccessServiceLegacyThreading.Read(Action`1 action, ProjectAccess flags, CancellationToken token)
       at Microsoft.VisualStudio.Project.Utilities.CommonProjectSystemTools.Read(IDirectAccessService directAccessService, ConfiguredProject configuredProject, Action`1 action, CancellationToken token)
       at Microsoft.VisualStudio.Project.ConfiguredProjectCache`1.ExecuteProjectReadSafely(Action`1 projectAccessDelegate)
       at Microsoft.VisualStudio.Project.ConfiguredProjectCache`1.RefreshValueIfAppropriate(Boolean proactive, CacheValidity cacheStatus)
       at Microsoft.VisualStudio.Project.ConfiguredProjectCache`1.<>c__DisplayClassa.<GetValue>b__7(IDirectAccess access)
       at Microsoft.VisualStudio.Project.Utilities.CommonProjectSystemTools.<>c__DisplayClass43`1.<Read>b__42(IDirectReadAccess directAccess)
       at Microsoft.VisualStudio.Project.DirectAccessService.AccessProject[T](Action`1 action, T directAccess, CancellationToken token, LockStats stats)
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
       at Microsoft.VisualStudio.Project.Utilities.CommonProjectSystemTools.Rethrow(Exception ex)
       at Microsoft.VisualStudio.Project.DirectAccessServiceLegacyThreading.MarshalToLockingThread[T](Action`1 action, T directAccess, CancellationToken token)
       at Microsoft.VisualStudio.Project.DirectAccessService.UpgradeableRead(Action`1 action, ProjectAccess flags, CancellationToken token)
       at Microsoft.VisualStudio.Project.DirectAccessServiceLegacyThreading.UpgradeableRead(Action`1 action, ProjectAccess flags, CancellationToken token)
       at Microsoft.VisualStudio.Project.DirectAccessServiceLegacyThreading.Read(Action`1 action, ProjectAccess flags, CancellationToken token)
       at Microsoft.VisualStudio.Project.Utilities.CommonProjectSystemTools.Read[T](IDirectAccessService directAccessService, Func`2 action)
       at Microsoft.VisualStudio.Project.ConfiguredProjectCache`1.GetValue(Boolean proactive, Boolean& upToDateValue)
       at Microsoft.VisualStudio.Project.ConfiguredProjectCache`1.get_Value()
       at Microsoft.VisualStudio.Project.Properties.ItemProperties.GetEvaluatedPropertyValue(String propertyName, IDirectReadAccess access)
       at Microsoft.VisualStudio.Project.Properties.ProjectPropertiesBase.<>c__DisplayClass7.<Microsoft.VisualStudio.Project.Properties.IProjectProperties.GetEvaluatedPropertyValue>b__6(IDirectReadAccess access)
       at Microsoft.VisualStudio.Project.DirectAccessService.AccessProject[T](Action`1 action, T directAccess, CancellationToken token, LockStats stats)
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
       at Microsoft.VisualStudio.Project.Utilities.CommonProjectSystemTools.Rethrow(Exception ex)
       at Microsoft.VisualStudio.Project.DirectAccessServiceLegacyThreading.MarshalToLockingThread[T](Action`1 action, T directAccess, CancellationToken token)
       at Microsoft.VisualStudio.Project.DirectAccessService.UpgradeableRead(Action`1 action, ProjectAccess flags, CancellationToken token)
       at Microsoft.VisualStudio.Project.DirectAccessServiceLegacyThreading.UpgradeableRead(Action`1 action, ProjectAccess flags, CancellationToken token)
       at Microsoft.VisualStudio.Project.DirectAccessServiceLegacyThreading.Read(Action`1 action, ProjectAccess flags, CancellationToken token)
       at Microsoft.VisualStudio.Project.Properties.ProjectPropertiesBase.Microsoft.VisualStudio.Project.Properties.IProjectProperties.GetEvaluatedPropertyValue(String propertyName)
       at Microsoft.VisualStudio.Project.Items.ProjectItemSchemaManager.GetContentType(IProjectItem item)
       at Microsoft.VisualStudio.Project.VisualC.VCProjectEngine.VCProjectShim.FindAndMoveDependentFiles(VCFile file)
       at Microsoft.VisualStudio.Project.VisualC.VCProjectEngine.VCFilterShim.<>c__DisplayClass11.<AddFile>b__10()
       at Microsoft.VisualStudio.Project.VisualC.VCProjectEngine.ApartmentMarshaler.Invoke[TResult](Func`1 method)
       at Microsoft.VisualStudio.Project.VisualC.VCProjectEngine.VCFilterShim.AddFile(String path)
       at Microsoft.VisualStudio.Project.VisualC.VCProjectEngine.VCProjectShim.<>c__DisplayClass16.<AddFile>b__15()
       at Microsoft.VisualStudio.Project.VisualC.VCProjectEngine.ApartmentMarshaler.Invoke(Action method)
       at Microsoft.VisualStudio.Project.VisualC.VCProjectEngine.VCProjectShim.AddFile(String path)
       at IceBuilder.VCUtilI.AddToFilter(Project dteProject, String name, String path)
       at IceBuilder.ProjectUtil.SetupGenerated(Project project, String file) in c:\Users\pepe\Documents\ZeroC\ice-builder-visualstudio\IceBuilder\ProjectUtil.cs:line 344
       at IceBuilder.DocumentEventHandler.OnAfterAddFilesEx(Int32 projectsLength, Int32 filesLength, IVsProject[] projects, Int32[] indices, String[] paths, VSADDFILEFLAGS[] rgFlags) in c:\Users\pepe\Documents\ZeroC\ice-builder-visualstudio\IceBuilder\DocumentEventHandler.cs:line 204Microsoft.VisualStudio.Project.ProjectException: Could not find project item with item type 'ClCompile' and include value 'generated\New3.cpp'.
       at Microsoft.VisualStudio.Project.Utilities.ProjectErrorUtilities.ThrowProjectExceptionHelper(Exception innerException, String unformattedMessage, Object[] args)
       at Microsoft.VisualStudio.Project.Utilities.ProjectErrorUtilities.ThrowProjectException(String message, Object arg0, Object arg1)
       at Microsoft.VisualStudio.Project.Properties.ItemProperties.<GetEvaluatedProjectItem>b__a(IDirectReadAccess access)
       at Microsoft.VisualStudio.Project.Utilities.CommonProjectSystemTools.<>c__DisplayClass43`1.<Read>b__42(IDirectReadAccess directAccess)
       at Microsoft.VisualStudio.Project.DirectAccessService.AccessProject[T](Action`1 action, T directAccess, CancellationToken token, LockStats stats)
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
       at Microsoft.VisualStudio.Project.Utilities.CommonProjectSystemTools.Rethrow(Exception ex)
       at Microsoft.VisualStudio.Project.DirectAccessServiceLegacyThreading.MarshalToLockingThread[T](Action`1 action, T directAccess, CancellationToken token)
       at Microsoft.VisualStudio.Project.DirectAccessService.UpgradeableRead(Action`1 action, ProjectAccess flags, CancellationToken token)
       at Microsoft.VisualStudio.Project.DirectAccessServiceLegacyThreading.UpgradeableRead(Action`1 action, ProjectAccess flags, CancellationToken token)
       at Microsoft.VisualStudio.Project.DirectAccessServiceLegacyThreading.Read(Action`1 action, ProjectAccess flags, CancellationToken token)
       at Microsoft.VisualStudio.Project.Utilities.CommonProjectSystemTools.Read[T](IDirectAccessService directAccessService, Func`2 action)
       at Microsoft.VisualStudio.Project.Properties.ItemProperties.GetEvaluatedProjectItem()
       at Microsoft.VisualStudio.Project.ConfiguredProjectCache`1.UpdateValueProjectAccessHelper(Project proj, Boolean proactive)
       at Microsoft.VisualStudio.Project.ConfiguredProjectCache`1.UpdateValueProjectAccessNotProactiveHelper(Project proj)
       at Microsoft.VisualStudio.Project.Utilities.CommonProjectSystemTools.<>c__DisplayClass55.<Read>b__54(IDirectReadAccess directAccess)
       at Microsoft.VisualStudio.Project.DirectAccessService.AccessProject[T](Action`1 action, T directAccess, CancellationToken token, LockStats stats)
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
       at Microsoft.VisualStudio.Project.Utilities.CommonProjectSystemTools.Rethrow(Exception ex)
       at Microsoft.VisualStudio.Project.DirectAccessServiceLegacyThreading.MarshalToLockingThread[T](Action`1 action, T directAccess, CancellationToken token)
       at Microsoft.VisualStudio.Project.DirectAccessService.UpgradeableRead(Action`1 action, ProjectAccess flags, CancellationToken token)
       at Microsoft.VisualStudio.Project.DirectAccessServiceLegacyThreading.UpgradeableRead(Action`1 action, ProjectAccess flags, CancellationToken token)
       at Microsoft.VisualStudio.Project.DirectAccessServiceLegacyThreading.Read(Action`1 action, ProjectAccess flags, CancellationToken token)
       at Microsoft.VisualStudio.Project.Utilities.CommonProjectSystemTools.Read(IDirectAccessService directAccessService, ConfiguredProject configuredProject, Action`1 action, CancellationToken token)
       at Microsoft.VisualStudio.Project.ConfiguredProjectCache`1.ExecuteProjectReadSafely(Action`1 projectAccessDelegate)
       at Microsoft.VisualStudio.Project.ConfiguredProjectCache`1.RefreshValueIfAppropriate(Boolean proactive, CacheValidity cacheStatus)
       at Microsoft.VisualStudio.Project.ConfiguredProjectCache`1.<>c__DisplayClassa.<GetValue>b__7(IDirectAccess access)
       at Microsoft.VisualStudio.Project.Utilities.CommonProjectSystemTools.<>c__DisplayClass43`1.<Read>b__42(IDirectReadAccess directAccess)
       at Microsoft.VisualStudio.Project.DirectAccessService.AccessProject[T](Action`1 action, T directAccess, CancellationToken token, LockStats stats)
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
       at Microsoft.VisualStudio.Project.Utilities.CommonProjectSystemTools.Rethrow(Exception ex)
       at Microsoft.VisualStudio.Project.DirectAccessServiceLegacyThreading.MarshalToLockingThread[T](Action`1 action, T directAccess, CancellationToken token)
       at Microsoft.VisualStudio.Project.DirectAccessService.UpgradeableRead(Action`1 action, ProjectAccess flags, CancellationToken token)
       at Microsoft.VisualStudio.Project.DirectAccessServiceLegacyThreading.UpgradeableRead(Action`1 action, ProjectAccess flags, CancellationToken token)
       at Microsoft.VisualStudio.Project.DirectAccessServiceLegacyThreading.Read(Action`1 action, ProjectAccess flags, CancellationToken token)
       at Microsoft.VisualStudio.Project.Utilities.CommonProjectSystemTools.Read[T](IDirectAccessService directAccessService, Func`2 action)
       at Microsoft.VisualStudio.Project.ConfiguredProjectCache`1.GetValue(Boolean proactive, Boolean& upToDateValue)
       at Microsoft.VisualStudio.Project.ConfiguredProjectCache`1.get_Value()
       at Microsoft.VisualStudio.Project.Properties.ItemProperties.GetEvaluatedPropertyValue(String propertyName, IDirectReadAccess access)
       at Microsoft.VisualStudio.Project.Properties.ProjectPropertiesBase.<>c__DisplayClass7.<Microsoft.VisualStudio.Project.Properties.IProjectProperties.GetEvaluatedPropertyValue>b__6(IDirectReadAccess access)
       at Microsoft.VisualStudio.Project.DirectAccessService.AccessProject[T](Action`1 action, T directAccess, CancellationToken token, LockStats stats)
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
       at Microsoft.VisualStudio.Project.Utilities.CommonProjectSystemTools.Rethrow(Exception ex)
       at Microsoft.VisualStudio.Project.DirectAccessServiceLegacyThreading.MarshalToLockingThread[T](Action`1 action, T directAccess, CancellationToken token)
       at Microsoft.VisualStudio.Project.DirectAccessService.UpgradeableRead(Action`1 action, ProjectAccess flags, CancellationToken token)
       at Microsoft.VisualStudio.Project.DirectAccessServiceLegacyThreading.UpgradeableRead(Action`1 action, ProjectAccess flags, CancellationToken token)
       at Microsoft.VisualStudio.Project.DirectAccessServiceLegacyThreading.Read(Action`1 action, ProjectAccess flags, CancellationToken token)
       at Microsoft.VisualStudio.Project.Properties.ProjectPropertiesBase.Microsoft.VisualStudio.Project.Properties.IProjectProperties.GetEvaluatedPropertyValue(String propertyName)
       at Microsoft.VisualStudio.Project.Items.ProjectItemSchemaManager.GetContentType(IProjectItem item)
       at Microsoft.VisualStudio.Project.VisualC.VCProjectEngine.VCProjectShim.FindAndMoveDependentFiles(VCFile file)
       at Microsoft.VisualStudio.Project.VisualC.VCProjectEngine.VCFilterShim.<>c__DisplayClass11.<AddFile>b__10()
       at Microsoft.VisualStudio.Project.VisualC.VCProjectEngine.ApartmentMarshaler.Invoke[TResult](Func`1 method)
       at Microsoft.VisualStudio.Project.VisualC.VCProjectEngine.VCFilterShim.AddFile(String path)
       at Microsoft.VisualStudio.Project.VisualC.VCProjectEngine.VCProjectShim.<>c__DisplayClass16.<AddFile>b__15()
       at Microsoft.VisualStudio.Project.VisualC.VCProjectEngine.ApartmentMarshaler.Invoke(Action method)
       at Microsoft.VisualStudio.Project.VisualC.VCProjectEngine.VCProjectShim.AddFile(String path)
       at IceBuilder.VCUtilI.AddToFilter(Project dteProject, String name, String path)
       at IceBuilder.ProjectUtil.SetupGenerated(Project project, String file) in c:\Users\pepe\Documents\ZeroC\ice-builder-visualstudio\IceBuilder\ProjectUtil.cs:line 344
       at IceBuilder.DocumentEventHandler.OnAfterAddFilesEx(Int32 projectsLength, Int32 filesLength, IVsProject[] projects, Int32[] indices, String[] paths, VSADDFILEFLAGS[] rgFlags) in c:\Users\pepe\Documents\ZeroC\ice-builder-visualstudio\IceBuilder\DocumentEventHandler.cs:line 204
    Any ideas what could be causing this?

    Monday, August 10, 2015 7:29 PM

Answers

  • Rebuild with VS2012 update 5 and problem goes away, seems something gots fixed.
    • Marked as answer by pepone.onrez Friday, September 4, 2015 5:57 PM
    Friday, September 4, 2015 5:57 PM

All replies

  • Updated the code to use EnvDTE.ProjectItems.AddFromFile but get a similar stack trace

    Microsoft.VisualStudio.Project.ProjectException: Could not find project item with item type 'ClCompile' and include value 'generated\sNew2.cpp'.
       at Microsoft.VisualStudio.Project.Utilities.ProjectErrorUtilities.ThrowProjectExceptionHelper(Exception innerException, String unformattedMessage, Object[] args)
       at Microsoft.VisualStudio.Project.Utilities.ProjectErrorUtilities.ThrowProjectException(String message, Object arg0, Object arg1)
       at Microsoft.VisualStudio.Project.Properties.ItemProperties.<GetEvaluatedProjectItem>b__a(IDirectReadAccess access)
       at Microsoft.VisualStudio.Project.Utilities.CommonProjectSystemTools.<>c__DisplayClass43`1.<Read>b__42(IDirectReadAccess directAccess)
       at Microsoft.VisualStudio.Project.DirectAccessService.AccessProject[T](Action`1 action, T directAccess, CancellationToken token, LockStats stats)
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
       at Microsoft.VisualStudio.Project.Utilities.CommonProjectSystemTools.Rethrow(Exception ex)
       at Microsoft.VisualStudio.Project.DirectAccessServiceLegacyThreading.MarshalToLockingThread[T](Action`1 action, T directAccess, CancellationToken token)
       at Microsoft.VisualStudio.Project.DirectAccessService.UpgradeableRead(Action`1 action, ProjectAccess flags, CancellationToken token)
       at Microsoft.VisualStudio.Project.DirectAccessServiceLegacyThreading.UpgradeableRead(Action`1 action, ProjectAccess flags, CancellationToken token)
       at Microsoft.VisualStudio.Project.DirectAccessServiceLegacyThreading.Read(Action`1 action, ProjectAccess flags, CancellationToken token)
       at Microsoft.VisualStudio.Project.Utilities.CommonProjectSystemTools.Read[T](IDirectAccessService directAccessService, Func`2 action)
       at Microsoft.VisualStudio.Project.Properties.ItemProperties.GetEvaluatedProjectItem()
       at Microsoft.VisualStudio.Project.ConfiguredProjectCache`1.UpdateValueProjectAccessHelper(Project proj, Boolean proactive)
       at Microsoft.VisualStudio.Project.ConfiguredProjectCache`1.UpdateValueProjectAccessNotProactiveHelper(Project proj)
       at Microsoft.VisualStudio.Project.Utilities.CommonProjectSystemTools.<>c__DisplayClass55.<Read>b__54(IDirectReadAccess directAccess)
       at Microsoft.VisualStudio.Project.DirectAccessService.AccessProject[T](Action`1 action, T directAccess, CancellationToken token, LockStats stats)
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
       at Microsoft.VisualStudio.Project.Utilities.CommonProjectSystemTools.Rethrow(Exception ex)
       at Microsoft.VisualStudio.Project.DirectAccessServiceLegacyThreading.MarshalToLockingThread[T](Action`1 action, T directAccess, CancellationToken token)
       at Microsoft.VisualStudio.Project.DirectAccessService.UpgradeableRead(Action`1 action, ProjectAccess flags, CancellationToken token)
       at Microsoft.VisualStudio.Project.DirectAccessServiceLegacyThreading.UpgradeableRead(Action`1 action, ProjectAccess flags, CancellationToken token)
       at Microsoft.VisualStudio.Project.DirectAccessServiceLegacyThreading.Read(Action`1 action, ProjectAccess flags, CancellationToken token)
       at Microsoft.VisualStudio.Project.Utilities.CommonProjectSystemTools.Read(IDirectAccessService directAccessService, ConfiguredProject configuredProject, Action`1 action, CancellationToken token)
       at Microsoft.VisualStudio.Project.ConfiguredProjectCache`1.ExecuteProjectReadSafely(Action`1 projectAccessDelegate)
       at Microsoft.VisualStudio.Project.ConfiguredProjectCache`1.RefreshValueIfAppropriate(Boolean proactive, CacheValidity cacheStatus)
       at Microsoft.VisualStudio.Project.ConfiguredProjectCache`1.<>c__DisplayClassa.<GetValue>b__7(IDirectAccess access)
       at Microsoft.VisualStudio.Project.Utilities.CommonProjectSystemTools.<>c__DisplayClass43`1.<Read>b__42(IDirectReadAccess directAccess)
       at Microsoft.VisualStudio.Project.DirectAccessService.AccessProject[T](Action`1 action, T directAccess, CancellationToken token, LockStats stats)
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
       at Microsoft.VisualStudio.Project.Utilities.CommonProjectSystemTools.Rethrow(Exception ex)
       at Microsoft.VisualStudio.Project.DirectAccessServiceLegacyThreading.MarshalToLockingThread[T](Action`1 action, T directAccess, CancellationToken token)
       at Microsoft.VisualStudio.Project.DirectAccessService.UpgradeableRead(Action`1 action, ProjectAccess flags, CancellationToken token)
       at Microsoft.VisualStudio.Project.DirectAccessServiceLegacyThreading.UpgradeableRead(Action`1 action, ProjectAccess flags, CancellationToken token)
       at Microsoft.VisualStudio.Project.DirectAccessServiceLegacyThreading.Read(Action`1 action, ProjectAccess flags, CancellationToken token)
       at Microsoft.VisualStudio.Project.Utilities.CommonProjectSystemTools.Read[T](IDirectAccessService directAccessService, Func`2 action)
       at Microsoft.VisualStudio.Project.ConfiguredProjectCache`1.GetValue(Boolean proactive, Boolean& upToDateValue)
       at Microsoft.VisualStudio.Project.ConfiguredProjectCache`1.get_Value()
       at Microsoft.VisualStudio.Project.Properties.ItemProperties.GetEvaluatedPropertyValue(String propertyName, IDirectReadAccess access)
       at Microsoft.VisualStudio.Project.Properties.ProjectPropertiesBase.<>c__DisplayClass7.<Microsoft.VisualStudio.Project.Properties.IProjectProperties.GetEvaluatedPropertyValue>b__6(IDirectReadAccess access)
       at Microsoft.VisualStudio.Project.DirectAccessService.AccessProject[T](Action`1 action, T directAccess, CancellationToken token, LockStats stats)
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
       at Microsoft.VisualStudio.Project.Utilities.CommonProjectSystemTools.Rethrow(Exception ex)
       at Microsoft.VisualStudio.Project.DirectAccessServiceLegacyThreading.MarshalToLockingThread[T](Action`1 action, T directAccess, CancellationToken token)
       at Microsoft.VisualStudio.Project.DirectAccessService.UpgradeableRead(Action`1 action, ProjectAccess flags, CancellationToken token)
       at Microsoft.VisualStudio.Project.DirectAccessServiceLegacyThreading.UpgradeableRead(Action`1 action, ProjectAccess flags, CancellationToken token)
       at Microsoft.VisualStudio.Project.DirectAccessServiceLegacyThreading.Read(Action`1 action, ProjectAccess flags, CancellationToken token)
       at Microsoft.VisualStudio.Project.Properties.ProjectPropertiesBase.Microsoft.VisualStudio.Project.Properties.IProjectProperties.GetEvaluatedPropertyValue(String propertyName)
       at Microsoft.VisualStudio.Project.Items.ProjectItemSchemaManager.GetContentType(IProjectItem item)
       at Microsoft.VisualStudio.Project.VisualC.VCProjectEngine.VCProjectShim.FindAndMoveDependentFiles(VCFile file)
       at Microsoft.VisualStudio.Project.VisualC.VCProjectEngine.VCFilterShim.<>c__DisplayClass11.<AddFile>b__10()
       at Microsoft.VisualStudio.Project.VisualC.VCProjectEngine.ApartmentMarshaler.Invoke[TResult](Func`1 method)
       at Microsoft.VisualStudio.Project.VisualC.VCProjectEngine.VCFilterShim.AddFile(String path)
       at Microsoft.VisualStudio.Project.VisualC.VCProjectEngine.VCProjectShim.<>c__DisplayClass16.<AddFile>b__15()
       at Microsoft.VisualStudio.Project.VisualC.VCProjectEngine.ApartmentMarshaler.Invoke(Action method)
       at Microsoft.VisualStudio.Project.VisualC.VCProjectEngine.VCProjectShim.AddFile(String path)
       at EnvDTE.ProjectItems.AddFromFile(String FileName)
       at IceBuilder.ProjectUtil.SetupGenerated(Project project, String file) in c:\Users\pepe\Documents\ZeroC\ice-builder-visualstudio\IceBuilder\ProjectUtil.cs:line 340
       at IceBuilder.DocumentEventHandler.OnAfterAddFilesEx(Int32 projectsLength, Int32 filesLength, IVsProject[] projects, Int32[] indices, String[] paths, VSADDFILEFLAGS[] rgFlags) in c:\Users\pepe\Documents\ZeroC\ice-builder-visualstudio\IceBuilder\DocumentEventHandler.cs:line 204


    • Edited by pepone.onrez Tuesday, August 11, 2015 8:32 AM update stack trace
    Tuesday, August 11, 2015 8:20 AM
  • This problem seems to be specif to Visual Studio 2012 update 4, it didn't happen with update 3.
    Tuesday, August 11, 2015 10:22 AM
  • Can you post the specifics on when/where you are invoking AddFromFile from, and how you retrieve the ProjectItems interface? Callstack in and of itself isn't terribly useful, without the details on how to potentially repro the behavior.

    Is this in a VsPackage, Add-in, or Wizard? What precisely is that IceBuilder component?

    Thanks,


    Ed Dore

    Tuesday, August 11, 2015 7:42 PM
  • Hi Ed

    IceBuilder is my Visual Studio package, source code available on github

    I have an event handler for DocumentEventHandler.OnAfterAddFilesEx, when a .ice (Slice definition) file is added I add .cpp/.h files to the project.

    You can see the event handler code here this call the setupGenerated method that adds the generated .cpp/.h files to the project if required.

    The relevant code for setupGenerated is this:

    EnvDTE.ProjectItem item = FindProjectItem(generatedFile, project.ProjectItems);
    if(item == null)
    {
        if (DTEUtil.IsCppProject(project))
        {
            String filter = KnownHeaderExtension.Contains(
                Path.GetExtension(generatedFile)) ? "Header Files" : "Source Files";
    
            Package.Instance.VCUtil.AddToFilter(project, filter, generatedFile);
        }
        else
        {
            project.ProjectItems.AddFromFile(generatedFile);
        }
    }

    See full code

    VCUtil.AddToFilter is implemented in a separate DLL that is loaded dynamically so that it uses the correct VC references for the different VS versions.

    public void AddToFilter(EnvDTE.Project dteProject, String name, String path)
    {
        VCProject project = dteProject.Object as VCProject;
    
        VCFilter filter = null;
        foreach (VCFilter f in project.Filters)
        {
            if (f.Name.Equals(name))
            {
                filter = f;
                break;
            }
        }
    
        if (filter != null)
        {
            filter.AddFile(path);                
        }
        else
        {
            project.AddFile(path);
        }
    }
    

    See full code

    The first stack I posted correspond to the call filter.AddFile above, the second stack correspond to change the line

    Package.Instance.VCUtil.AddToFilter(project, filter, generatedFile);
    

    By:

    project.ProjectItems.AddFromFile(generatedFile);
    

    I use the same code for Visual Studio 2012, 2013 and 2015, and I just getting this failures with Visual Studio 2012 update 4, It worked fine with Update 3.

    Tuesday, August 11, 2015 9:43 PM
  • That's definitely odd. Especially the part about this only reproducing with VS2012 Update 4.

    I've got a VS 2012 install here somewhere :-). If I pull this off GitHub, what are the steps to follow to reproduce the issue?

    Thanks,
    Ed...


    Ed Dore

    Wednesday, August 12, 2015 10:41 PM
  • Hi Ed,

    You will need to install Ice-3.6.0.msi from our web site, this is required so that the extension doesn't complain about non Ice SDK found.

    Then open IceBuilder solution from the cloned repository

    Set IceBuilder as the start project and in the Debug properties setup it to start external program "C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\devenv.exe" and add the command line argument for "/RootSuffix Exp" and start a new debug session.

    Once Visual Studio starts create a new C++ console project, right click on the project and select "Ice Builder to Project"

    Then use "Add new Item" to add a Slice file to the project.

    This will trigger the exception when the builder try to add .cpp/.h files matching the new .ice file.


    • Edited by pepone.onrez Thursday, August 13, 2015 10:43 AM clarification
    Thursday, August 13, 2015 10:36 AM
  • Rebuild with VS2012 update 5 and problem goes away, seems something gots fixed.
    • Marked as answer by pepone.onrez Friday, September 4, 2015 5:57 PM
    Friday, September 4, 2015 5:57 PM