Maybe you are using an old .NET Framework. Try using .NET Framework 4.8 or .NET 5 or 6. What kind of project did you create?
Why isn't the GenerateKey method available for my ECDiffieHellmanCng object?
Documentation for the ECDiffieHellmanCng class shows a GenerateKey() method, but this method is not found/recognized in my project (Visual Studio 2019). Any thoughts on how I can get to this method?
Russ
4 additional answers
Sort by: Most helpful
-
AgaveJoe 26,161 Reputation points
2022-01-06T18:52:54.57+00:00 The GenerateKey method is a member of the ECDiffieHellmanCng instance.
public static void Main(string[] args) { ECDiffieHellmanCng test = new ECDiffieHellmanCng(); test.GenerateKey(new ECCurve()); }
Share your code if need further assistance.
-
Russ Beech 41 Reputation points
2022-01-06T19:06:27.697+00:00 Yes, but it is not available for mine. Does not show up with Intellisense; if typed in completely is underlined in red and generates a Build error. It just isn't available (obviously, it is available to you). Wondering why I don't have it?
Russ
(I realize a key pair is generated when the instance is created, but I'd like to be able generate a new pair when desired.)
Russ
-
Russ Beech 41 Reputation points
2022-01-06T19:32:44.213+00:00 Guys, thanks for your input. I think the .net version is the problem. I noticed that the online documentation shows .net 6 for the ECDiffieHellmanCng class. While some of it seems to work with Visual Studio 2019 and .net 4, it appears that I need something newer to use the GenerateKey method. And, I see that I have to upgrade to Visual Studio 2022 in order to use .net 6. The install is underway, will know in a while if that fixes it.
Russ
-
Russ Beech 41 Reputation points
2022-01-06T20:43:44.773+00:00 Viorel-1,
Guess I should have tried 4.8 before upgrading to VS2022 (which I can't seem to get to give me .net 6 as an option) - turns out .net 4.8 gives me the GenerateKey() method, even with VS2019.