简体   繁体   中英

Visual studio C# packages

this is my problem with VS :S in the first project : System.Security.Cryptography.AesCryptoServiceProvider obj;
everything is ok
in the second project:
System.Security.Cryptography.AesCryptoServiceProvider obj1;
it doesn't recognize the AesCryptoServiceProvider?!!

is VS using different packages or what ?!

updated: changed the variable name but still not working

var is a reserved keyword. Use a different identifier name or @var .

System.Security.Cryptography.AesCryptoServiceProvider @var;

This may not be the problem - you need to ensure that each project has a reference to System.Core the assembly containing System.Security.Cryptography .

You will also need to ensure that you are targeting a framework version that contains this class (.NET 3.5 and above) - this can be done in the project property pages.

Are the references the same between both project? Just open references and see. I bet you are missing one. However, you really should use a different variable name than var. Also, can you post the exact error?

You can't name a variable var because it's a reserved word, use a different name, this will not cause an error :

System.Security.Cryptography.AesCryptoServiceProvider _var;

Edit :

AesCryptoServiceProvider is only supported in .Net framework 4 and 3.5 SP1, change the target framework and it will work and be sure to have System.Security.Cryptography; in that file.

Check if both your projects have System.Core on References. Probably just the first has. You've do add it on both to be able to use AesCryptoServiceProvider .

Moreover, as you can see here AesCryptoServiceProvider is only available since .NET 3.5. Check your projects properties, more specifically the Target Framework .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM