none
Why is the struct "ECParameters" not included in the “System.Security.Cryptography” namespace? RRS feed

  • Pergunta

  • When I am writing a C# program ES256_Verifier.cs in Visual Studio 2017 (the source codes are in the package zip file in Microsoft One-Drive https://onedrive.live.com/?cid=8FFA4A1C66CFCED9&id=8FFA4A1C66CFCED9%211067&parId=8FFA4A1C66CFCED9%211066&o=OneUp) to verify a JWT signed by a certificate based on ES256 algorithm, I hit the following compiler error messages:

    +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

    “Error CS0246: The type or namespace name 'ECPoint' could not be found (are you missing a using directive or an assembly reference?)”

    “Error    CS0246  The type or namespace name 'ECParameters' could not be found (are you missing a using directive or an assembly reference?)”

    +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

    The compilation error scenario can also refer to the red rectangles of the screenshot file ECParameters_could_not_be_found_compiler_error_message.jpg in the upload package in Microsoft One-Drive)

    However, I can make sure that I am “using” the “System.Security.Cryptography” namespace in my C# source codes, and also make reference to the DLL file System.Security.Cryptography.Algorithms.dll (see the green rectangle in the screenshot file ECParameters_could_not_be_found_compiler_error_message.jpg in the upload package in Microsoft One-Drive). The DLL file System.Security.Cryptography.Algorithms.dll that I am using is also included in the upload package. The versions of the DLL file is shown in the blue rectangles of the screenshot file ECParameters_could_not_be_found_compiler_error_message.jpg in the upload package in Microsoft One-Drive.

    Thereafter, I searched but found two contradictory URLs from https://docs.microsoft.com/en-us/dotnet/api/ website: in the URL https://docs.microsoft.com/en-us/dotnet/api/system.security.cryptography?view=dotnet-plat-ext-5.0, I cannot find any struct of “ECParameters” or “ECPoint” under the System.Security.Cryptography Namespace (see the screenshot file ECParameters_is_not_included_in_dotnet-plat-ext-5.0-name-space.jpg in the upload package); but in the URL https://docs.microsoft.com/en-us/dotnet/api/system.security.cryptography?view=net-5.0, I can find both the structs of “ECParameters” and “ECPoint” under the System.Security.Cryptography Namespace (see the screenshot file ECParameters_is_included_in_net-5.0-name-space.jpg in the upload package in Microsoft One-Drive).

    Now I am doubting whether I have used a wrong-version DLL file System.Security.Cryptography.Algorithms.dll. So can anybody show me how I can refer to a right-version DLL file which includes the “ECParameters” and “ECPoint” structs?

    Thanks.

     

    domingo, 24 de janeiro de 2021 15:21