Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KeyNotFoundException System.ComponentModel.Annotation #946

Open
bswift-kj opened this issue Nov 18, 2021 · 6 comments
Open

KeyNotFoundException System.ComponentModel.Annotation #946

bswift-kj opened this issue Nov 18, 2021 · 6 comments
Labels
community reported Triaged Label to show that UA team has triaged this issue.

Comments

@bswift-kj
Copy link

Describe the bug

We are trying to upgrade some class libraries, currently built in .NET Framework 4.7.2, and will occasionally get a KeyNotFound Exception that references System.ComponentModel.Annotations. However this reference is not located in this project. We are not sure why this is happening. We have spoken with Microsoft and they recommended that I ask here. I am happy to provide the .csproj file and .clef files if requested, but does not look like I can upload it here.
project_references

To Reproduce

Can supply project files if requested.

Exceptions (if any)

Annotation Error

Further technical details

  • Windows 64 bit
    github requests

Thank you for your help.

@sunandabalu
Copy link
Member

@bswift-kj Could you please provide the .csproj file you are using and also the .clef file for logs? If you are unable to upload here, feel free to email to [email protected]

@sunandabalu sunandabalu added the Triaged Label to show that UA team has triaged this issue. label Nov 30, 2021
@bswift-kj
Copy link
Author

I am unable to upload or email that emails address (RESOLVER.RST.SenderNotAuthenticatedForGroup; authentication required; Delivery restriction check failed because the sender was not authenticated when sending to this group).

@zdzdz
Copy link

zdzdz commented Feb 24, 2022

I'm experiencing absolutely the same issue.
I follow the guide from the documentation https://docs.microsoft.com/en-us/dotnet/core/porting/upgrade-assistant-aspnetmvc with absolutely freshly created MVC project (.net 4.5.2). I run the upgrade-assistant and second step that converts the project file fails with 'Unexpected error applying step
System.Collections.Generic.KeyNotFoundException: The given key 'System.ComponentModel.Annotations' was not present in the dictionary.'

I even excluded 'System.ComponentModel.DataAnnotations' and still same result.

@Natis88
Copy link

Natis88 commented Jun 1, 2022

any solution for this problem?

@sgalcheung
Copy link

Recently, I also meet the same issue, and found a relation issue

@sgalcheung
Copy link

sgalcheung commented Feb 9, 2023

  • Can not found dll,Could not load file or assembly 'System.ComponentModel.Annotations, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified
    • Use the dotnet-convert command to modify csproj to a new version of the template
    • After starting the host project, I found that the above exception was thrown
    • After analysis, it is found that it is called System. ComponentModel.DataAnnotations in netframework, and System. ComponentModel.Annotations in netstandard/netcore
    • At this time, use the multi-target version to solve this problem
    • First you need to add the corresponding target version, and then refer to different packages for different frameworks, as follows
<ItemGroup Condition="'$(TargetFramework)'=='net472' Or '$(TargetFramework)'=='net461'">
  <Reference Include="System.ComponentModel.DataAnnotations" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)'=='netstandard2.0'">
  <PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
</ItemGroup>

This solved my issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community reported Triaged Label to show that UA team has triaged this issue.
Projects
None yet
Development

No branches or pull requests

5 participants