11/24/2010 6:38:05 AM
 lengyang Posts: 6
|
Trial License - the following error raised when tried option Standardize Linq-to-Sql class and member names in Visual Studio 2010 .
Processing Linq-to-SQL classes and members Updating entity/member names failed due to exception: System.Security.Cryptography.CryptographicException: Key not valid for use in specified state.
at System.Security.Cryptography.Utils.CreateProvHandle(CspParameters parameters, Boolean randomKeyContainer) at System.Security.Cryptography.Utils.get_StaticDssProvHandle() at System.Security.Cryptography.DSACryptoServiceProvider.ImportParameters(DSAParameters parameters) at System.Security.Cryptography.DSA.FromXmlString(String xmlString) at HuagatiDBMLTools2010.License.IsValid() at HuagatiDBMLTools2010.DBMLNamingConventions.RenameEntities(DTE2 applicationObject, Document document)
|
|
0
• permalink
|
11/24/2010 7:13:41 AM
 Kristofer Andersson Moderator Posts: 312
|
Hi,
That exception indicates it failed to load the key used for license verification. I have attached a sample project that tests some operations involved in this; please try it and see if any of the debug.asserts fails if you run that project.
Best regards, Kristofer
|
|
0
• permalink
|
11/24/2010 7:42:38 AM
 lengyang Posts: 6
|
I run the TestApp and it indicates that the file HuagatiDBMLExtensions.dll.lic is missing.
-Environment: 64-bit Windows 7 OS -Both VS 2008 and VS 2010 installed. Files get installed into three folders C:\Program Files (x86)\Huagati Systems Co Ltd\ C:\Users\xx\Documents\Visual Studio 2008\Addins C:\Users\xx\Documents\Visual Studio 2010\Addins
|
|
0
• permalink
|
11/24/2010 7:48:08 AM
 Kristofer Andersson Moderator Posts: 312
|
Ok, but you get no error on any of the four crypto sign/verify tests?
The missing file error is not relevant since the test project is old and checks in the VS 2008 add-in directory. If you are using the add-in with Visual Studio 2010 then that file is located in the VS2010 add-in directory and is instead called HuagatiDBMLTools2010.dll.lic
|
|
0
• permalink
|
11/24/2010 4:07:01 PM
 lengyang Posts: 6
|
There was no error, but the file .lic is missing from both VS 2080 and VS 2010 Addins folder. C:\Users\xx\Documents\Visual Studio 2010\Addins\HuagatiDBMLExtensions.dll.lic
|
|
0
• permalink
|
11/25/2010 2:02:46 AM
 Kristofer Andersson Moderator Posts: 312
|
In the VS2010 version of the add-in, the license file is called HuagatiDBMLTools2010.dll.lic.
However, the stack trace indicates that something goes wrong when initializing the CSP that is used for validating the license key from a static string.
I have attached a new test app that uses the same key as the add-in. Can you try that one and see what happens?
|
|
0
• permalink
|
11/25/2010 4:47:45 AM
 lengyang Posts: 6
|
Here is the raised error. It did not work in VS 2010. Perhaps this MSDN article may help explain the problem.
http://social.msdn.microsoft.com/forums/en-US/clr/thread/4e3ada0a-bcaf-4c67-bdef-a6b15f5bfdce/
Initializing CSP failed: System.Security.Cryptography.CryptographicException: Ke y not valid for use in specified state.
at System.Security.Cryptography.Utils.CreateProvHandle(CspParameters paramete rs, Boolean randomKeyContainer) at System.Security.Cryptography.Utils.get_StaticDssProvHandle() at System.Security.Cryptography.DSACryptoServiceProvider.ImportParameters(DSA Parameters parameters) at System.Security.Cryptography.DSA.FromXmlString(String xmlString) at ConsoleApplication5.Program.Main(String[] args) in C:\Learn\ConsoleApplica tion5\ConsoleApplication5\Program.cs:line 18 Press Enter to continue
|
|
0
• permalink
|
11/25/2010 5:16:23 AM
 Kristofer Andersson Moderator Posts: 312
|
Thanks.
I have attached an updated version of the test code that will attempt to get hold of the hResult from the underlying crypto provider code; I would suspect some kind of permission error is involved.
Please run it and let me know what it returns.
|
|
0
• permalink
|
11/25/2010 6:19:29 AM
 lengyang Posts: 6
|
Here is the hresult:
Initializing CSP failed: System.Security.Cryptography.CryptographicException: Ke y not valid for use in specified state.
at System.Security.Cryptography.Utils.CreateProvHandle(CspParameters paramete rs, Boolean randomKeyContainer) at System.Security.Cryptography.Utils.get_StaticDssProvHandle() at System.Security.Cryptography.DSACryptoServiceProvider.ImportParameters(DSA Parameters parameters) at System.Security.Cryptography.DSA.FromXmlString(String xmlString) at Test.Main() HResult: 8009000b
Press Enter to continue
|
|
0
• permalink
|
11/25/2010 6:51:33 AM
 Kristofer Andersson Moderator Posts: 312
|
Thanks for the info, and for your patience in helping to track down this.
I'm looking into possible causes of that error, I suspect it may be some permissions problem since the error is returned from the underlying crypto-API methods. (The key is static and hasn't changed for years.) I will let you know as soon as I find out more...
If you recompile the test app using the .net framework 2.0 compiler ( csc testCSP.cs ), does it return the same error? Or does it work if run under .net framework 2.0?
Best regards, Kristofer
Ps. FYI: I also opened a SO thread to see if anyone there may have a better idea what can cause this particular error: http://stackoverflow.com/questions/4274062/importing-a-dsa-key-from-xml-string-fails-for-one-user-permissions-broken-insta
|
|
0
• permalink
|
11/25/2010 7:13:22 AM
 lengyang Posts: 6
|
The test app works fine on .NET 2.0, and failed when target .NET 4.0.
|
|
0
• permalink
|
11/25/2010 7:54:09 AM
 Kristofer Andersson Moderator Posts: 312
|
If you run the test-app as administrator, does that make any difference?
|
|
0
• permalink
|
11/25/2010 8:02:40 AM
 Kristofer Andersson Moderator Posts: 312
|
Can you try running the test app with procmon running? ( http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx )
Add filters to only include events from testCSP.exe and exclude everything that returns success. Hopefully that can reveal if it is caused by some permissions error or something else:
 edited by Kristofer on 11/25/2010
|
|
0
• permalink
|
11/25/2010 9:25:49 AM
 Kristofer Andersson Moderator Posts: 312
|
Also, please check if you have a file named "046668979d75ce83103c9cc4922671e4_" under %APPDATA%\Microsoft\Crypto\DSS\[SID]
If you do, try moving that file elsewhere temporarily and see if that changes anything. This could possibly be a conflict with some other pre-existing key.
Is your windows installation an upgrade from a previous version of Windows, or is it a new installation?
Do you have any special cryptographic hardware or software installed?
|
|
0
• permalink
|
11/29/2010 5:02:32 AM
 Kristofer Andersson Moderator Posts: 312
|
Update: this error is probably caused by a key container stored under %APPDATA%\Microsoft\Crypto\DSS\[SID] that can not be opened and/or has been corrupted.
This can happen if your windows password has been reset by an administrator; in that case you may need to rename or delete the key container under the above mentioned path. I'm adding some fallback logic in the next update (v 2.11), so that a more user friendly error message will be show and the license can be validated even if the DSA provider is unable to initialize properly.
|
|
0
• permalink
|