Cannot modify an evaluated object originating in an imported file
Asked Answered
B

7

17

I am trying to delete a file from my visual studio project, but this dialogue pops up and prevent me from doing that. What does it mean and how do I resolve this problem?

There is a xamarin thread about this but no solution there.

https://forums.xamarin.com/discussion/25719/cannot-modify-an-evaluated-object-originating-in-an-imported-file

enter image description here

Billi answered 7/3, 2016 at 22:15 Comment(0)
B
5

We have no idea what the real problem is, but we do find a fix by comparing this project with some other project files that we have.

The fix is to open the .Shared.vcxitems file in an text editor and replace this:

  <ItemGroup>
    <ProjectCapability Include="$(MSBuildThisFileDirectory)SourceItemsFromImports" />
  </ItemGroup>

with this

  <ItemGroup>
    <ProjectCapability Include="SourceItemsFromImports" />
  </ItemGroup>
Billi answered 8/3, 2016 at 14:53 Comment(0)
I
13

I ran across this question as well as a couple others related to the error message, specifically. My issue was different from the OP's as it had to do with NuGet packages not installing/uninstalling/updating.

I opened the .CSProj files only to see the package reference completely missing for Microsoft.NET.Test.Sdk, ie some VS file somewhere was caching this bad reference, even after killing all existing .vs directories. So I just added it manually, ran nuget restore, and was back in business.

Basically, I modified this block of project file XML:

  <ItemGroup>
    <PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform">
      <Version>6.2.8</Version>
    </PackageReference>
    <PackageReference Include="MSTest.TestAdapter">
      <Version>1.4.0</Version>
    </PackageReference>
    <PackageReference Include="MSTest.TestFramework">
      <Version>1.4.0</Version>
    </PackageReference>
  </ItemGroup>

to this:

  <ItemGroup>
    <PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform">
      <Version>6.2.8</Version>
    </PackageReference>
    <PackageReference Include="MSTest.TestAdapter">
      <Version>1.4.0</Version>
    </PackageReference>
    <PackageReference Include="MSTest.TestFramework">
      <Version>1.4.0</Version>
    </PackageReference>
    <PackageReference Include="Microsoft.NET.Test.Sdk">
      <Version>16.1.1</Version>
    </PackageReference>
  </ItemGroup>
Instal answered 13/6, 2019 at 0:32 Comment(4)
This modification to my .csproj was all it took to solve my problem. Thanks!Visible
This worked for my unit testing as well. Confirmed this is still a problem with a new VS2019 UWP unit test [1/27/2021] project. Good grief. Thank you for the tip.Eight
Life saver. Can also confirm this worked [20/03/2021]!Deemphasize
Thanks. This is still an issue in VS 2022 Community Unit test project and this solution still works.Shoreless
B
5

We have no idea what the real problem is, but we do find a fix by comparing this project with some other project files that we have.

The fix is to open the .Shared.vcxitems file in an text editor and replace this:

  <ItemGroup>
    <ProjectCapability Include="$(MSBuildThisFileDirectory)SourceItemsFromImports" />
  </ItemGroup>

with this

  <ItemGroup>
    <ProjectCapability Include="SourceItemsFromImports" />
  </ItemGroup>
Billi answered 8/3, 2016 at 14:53 Comment(0)
A
5

Restarting Visual Studio fixed the issue for me.

Accordion answered 5/12, 2016 at 12:52 Comment(0)
F
0

In my solution happend because there was NuGet packages source pointing to non-existent local folder, changed it in Package Manager Settings.

Fakir answered 2/7, 2019 at 12:8 Comment(0)
F
0

My workaround was to open the .vcxitems and .vcxitems.filters, mentioned in the error message, in text editor and delete the file directly in the xml. Also I want to note that this error appears for me only when I tried to delete files that were part of different .vcxitems that was imported into main project. You can check your main project for <Import Project="xyz.vcxitems" />.

Flaky answered 13/12, 2021 at 12:34 Comment(0)
J
0

For me, this was resolved by setting 'Default Package Management Format' to 'PackageReference' from 'PackageConfig' in Nuget Package Manager Settings

enter image description here

Jennifer answered 3/8, 2023 at 5:50 Comment(0)
C
0

I was also facing this issue with NuGet packages not installing/uninstalling/updating in VS2022.

I was able to solve the issue with below steps:-

  1. Go to Tools -> Nuget Package Manager -> Manage Nuget Packages for Solution...
  2. Go to Installed tab and click on the package which was giving this error for you.
  3. Make sure that the installed package version for all the proj files is same.

I re-installed the same package version for all projs and after that I was able to run my application without any issue.

Chalkstone answered 29/7 at 5:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.