strong name key corrupt or unreadable - visual-studio-2010

On an infrequent random interval, some projects in a solution won't build anymore. Probably because of the strong named key file beging corrupt or lost..
resulting in the following errors when building the project:
Error 1 Metadata file
'D:\CasparKleijne.Toolkit\CasparKleijne.Toolkit\bin\Debug\CasparKleijne.Toolkit.dll'
could not be
found CasparKleijne.Toolkit.Reporting
Error 2 Cannot import the following key file:
CasparKleijne.Toolkit.pfx. The
key file may be password protected. To
correct this, try to import the
certificate again or manually install
the certificate to the Strong Name CSP
with the following key container name:
VS_KEY_11D604D4C94AB54 CasparKleijne.Toolkit
Error 3 Importing key file
"CasparKleijne.Toolkit.pfx" was
canceled. CasparKleijne.Toolkit
(assembly names are changed for some privacy reasons)
But the file is at the exact same location where it was, but I cannot import it anymore. I have to create a new one and all works fine again.
How can a file be at the correct location but still not be found by vs2010? what is this mystery? How can I avoid this?

Wild guesses:
Check your build configuration and ensure that project is set to build. Make sure it is not getting switched.
Otherwise, in my experience, weird problems like that are ususally due to Visual Studio caching things on its own.
There is no reliable way (or at least I haven't found yet) to detect what or where to look. I generally resort to a 'rinse-n-repeat' procedure:
Delete all obj/debug folders
Clear you temp directory
Close all VS instances and restart your IDE.
Do a rebuild

Its looking for a pfx file. I think that's a certificate file format. Maybe the certificate expired, or like the message said, it is password protected.

Related

SSIS: Package password error when building

We have several hundred SSIS packages in a Visual Studio Integration Services project. When this was originally set up it was configured to encrypt sensitive data in the packages with the user key. This caused some issues for us when the project file was checked out and we had conflicts because, of course, our different developer user keys were different.
We just attempted to change to sensitive data with password. To do that we had to update the project property and then we had to do it for every package manually (I tried looping using dtutil.exe but for some reason it did not work). To build my project I had to open every single package, change the password, and then build the project. After a few hours of this and getting every package updated and saved I was able to build and deploy my packages.
After that I did a commit/push to source control (Azure Git) and when my co-worker did a pull and opened the project they are now unable to build with the same error. If he puts the password in and checks everything in and I pull it back down, I get the error again.
The package and project passwords match, I can build, but when it's pulled down we get the error.
The error is:
"Project consistency check failed. The following inconsistencies were detected:
[package Name] has a different password than the project"
I was able to get around this issue but I was not able to figure out exactly what is occurring. I basically changed my protection level to DontSaveSensitive and made sure all of my passwords and sensitive information were parameterized and passed in using SSIS environment variables.
So after making sure all sensitive data was not saved in the packages I changed the project protection level and the protection level of every package. I changed the packages using this code:
for %f IN (*.dtsx) DO dtutil.exe /file %f /encrypt file;%f;0 /quiet
This changed the setting for the packages but I still received the error when building. I had to open each package, change the protection level property to any other value then back to DontSaveSensitive and then build. Once I did that the items fell out of the error message. After doing that manually for 650+ packages I was able to build. The most important resolution was that once I did a push and my co-worker pulled the changes down, they did not have to edit each package. When I was using encrypt sensitive with password we could not stop it from requiring a change and build on every package.
This is still a bit of a mystery, why dtutil.exe would not just change them without needing to re-build is very frustrating. But this work around ultimately got us past the problem and parameterizing was probably the best practice anyway.
I just had the same issue, my problem was that I was missing to introduce the password in the properties of every package (not only in the project), after doing that I have been able to rebuild the project.

Sonar Strange Encoding Issue?

I recently rolled out an update for Jenkins to kick off sonar-scanner on version 5.6 of SonarQube. I'm not using the plugin, just a command line call of the sonar scanner from the directory where the sonar-project.properties file resides.
So far all of the developers have followed the same steps, and configure the properties file for their services and works great except in a few cases. Two developers have had a strange issue, when an error message prompts:
"Caused by: Not authorized. Analyzing this project requires to be authenticated. Please provide the values of the properties sonar.login and sonar.password."
I thought this to be strange because the other developers would probably have the same issue if the authentication token I used in the instructions was wrong. I compared a working copy with the version the first developer and the only difference was the project specific things such as DLL name, version, etc... I'll provide a template below. With the file looking fine, I saved off the broken copy, and copied the contents of another working copy into the broken copy. I then changed the project specific properties, and commit into subversion. Sonar scans successfully!
Out of curiosity, I then compared the old broken file and the new working copy line by line. Their was absolutely no difference between any character. I then thought this must be an encoding issue. I did a quick test by adding the sonar encoding property, commit this back and the scan failed. So I then changed back to the working copy and just continued.
The next day a second developer came to me with the same exact issue. I then tried the same previous steps where I copied the contents of a working copy, and pasted into the new, and commit this back in. However this time the workaround did not work. In fact, I tried about 5 different working copies to paste into and they all failed with that authorization error. I know the properties file is exactly correct with the token and such.
I'm not sure what to do at this point, I haven't come across any logs on the server that indicate any good information to me unless their is a log I'm unaware of.
# Token
sonar.login=SOMESECRETTOKEN
# Unique project key for sonar
sonar.projectKey=SOMESERVICE
# UI Settings for sonar
sonar.projectName=SOMESERVICE
sonar.projectVersion=SOMEVERSION
# Path to source, if not set it searches from this
# file's directory
sonar.sources=.
# Encoding of the source code. Default is default system encoding
#sonar.sourceEncoding=UTF-8
#Cop
sonar.stylecop.projectFilePath=./SOMEPROJ.csproj
sonar.cs.fxcop.assembly=./bin/Release/SOMEDLL.dll
sonar.cs.fxcop.fxCopCmdPath=C:/Program Files (x86)/Microsoft Fxcop 10.0/FxCopCmd.exe
sonar.fxcop.assemblies=./bin/Release/SOMEDLL.dll
Any helps or pointers is appreciated, thanks!
This isn't about your encoding or file contents, but about permissions. The user that runs the scan doesn't have Execute Analysis permissions on the projects in question.
And to create new projects with the first analysis, the user must also have the Create Projects permission.
When encountering this issue, I loaded the file in Notepad++ which told me the file was saved under some strange encoding visual studio gave text files. I fixed it by switched the encoding to UTF-8 which resolved the problem. This probably should be handled better in Sonar!

Signing Visual Studio manifest with PFX fails

I am having an issue that seems to have been discussed on several occasions, but alas no solution seems to work for me. I am running VS 2013 on VMWare (on Mac) trying to publish a ClickOnce project.
Initially, I installed certificate from Windows Explorer, chose it from Store, and then from drop down list below to get
An attempt was made to reference a token that does not exist
The error does not go away after delete / repeat cycle. It only works with my personally created PFX files (obviously, not good for deployment).
I then tried exporting, uninstalling, then installing using command line, namely
certutil -importPFX -user <name.pfx> AT_SIGNATURE
But the problem persisted. At some it started working, but then I got the
Cannot import the following key file: companyname.pfx. The key file may be password protected. To correct this, try to import the certificate again or manually install the certificate to the Strong Name CSP with the following key container name: VS_KEY_3E185446540E7F7A
Running
sn -i <certificate.pfx> VS_KEY_XXXXXXX
Does not change anything.
I feel really lost here and would highly appreciate any help.

ClickOnce Error "different computed hash than specified in manifest" when transferring published files

I am in an interesting situation where I maintain the code for a program that is used and distributed primarily by our sister company. We are ready to distribute the program to all of the 3rd party users and since it is technically our sister companies program, we want to host it on their website. (in the interest of anonimity, I'll use 'program' everywhere instead of the actual application name, and 'www.SisterCompany.com' instead of their actual URL.)
So I get everything ready to go, setup the Publish setting to check for updates at program start, the minimum required version, and I set the Insallation Folder URL and Update Location to "http://www.SisterCompany.com/apps/program/", with the actual Publishing Folder Location as "C:\LocalProjects\Program\Publish\". Everything else is pretty standard.
After publish, I confirm that everything installs and works correctly when running directly from the publish location on my C: drive. So I put everything on our FTP server, and the guy at our sister company pulls it down and places everything in the '/apps/program/' directory on their webserver.
This is where it goes bad. When I try to install it from their site, I get the - File, Program.exe.config, has a different computed hash than specified in manifest. Error. I tested it a bit, and I even get that error trying to install from any network location on our network other than my local C: drive.
After doing the initial publish in visual studio, I have changed no files (which is the answer/reason I've found by doing some searching about this error).
What could be causing this? Is it because I set the Installation Folder URL to a location that it isn't initially published too?
Let me know if any additional info is needed.
Thanks.
After bashing my head against this all weekend, I have finally found the answer. After unsigning the project and removing the hash on the offending file (an xml file), I got the program to install, but it was giving me 'Windows Side by Side' Errors. I drilled down into the App Cache were the file was, and instead of a config .xml file, it was one of the HTML files from the website the clickonce installer was hosted on. Turns out that the web server didn't seem to like serving up an .XML (or .mdb it turns out) file.
This MSDN article ended up giving me the final solution:
I had to make sure that the 'Use ".deploy" file extension' was selected so that the web server wouldn't mangle files with extensions it didn't like.
I couldn't figure out why that one file's hash would be different. Turns out it wasn't even the same file at all.
It is possible that one of the FTP transfers is happening in text mode, rather than binary?
For me the problem was that .config transformations were done after generating manifest.
To anyone else who's still having trouble, five years later:
The first problem was configuring the MIME type, which on nginx (/etc/nginx/mime.types) should look like this:
application/x-ms-manifest application
See Click Once Server and Client Configuration.
The weirder problem to me was that I was using git to handle the push to the server, i.e.
git remote add live ssh://user#mybox/path/to/publish
git commit -am "committing...";git push live master
Works great for most things, but it was probably being registered as a "change," which prevented the app from installing locally. Once I started using scp instead:
scp -r * user#mybox/path/to/dir/
It worked without a hitch.
It is unfortunate that there is not a lot of helpful information out there about this.

Unable to access Temp files while debugging winForms project in Visual Studios 2010

I have several programs that I have created in vb.net visual studios 2010. I have been working on these programs for months with no problems. Recently I started having an issue where I can no longer access my temp directory while debugging within VS. I can't use My.Settings anymore because these use those temp files. This is the error I get:
Failed to save settings: An error occurred loading a configuration file: Could not find a part of the path 'C:\Users\USERNAME\AppData\Local\PROGNAME\PROGNAME.exe_Url_gty0snnfox5ji5xgprklljwb0e0mthek\1.0.0.0\nl3u0fw2.tmp'. (C:\Users\USERNAME\AppData\Local\PROGNAME\PROGNAME.exe_Url_gty0snnfox5ji5xgprklljwb0e0mthek\1.0.0.0\user.config)*
This file is there though.
I also get an error when trying to use my web services. I get this error:
Access to the temp directory is denied. Identity 'DOMAIN\Username' under which XmlSerializer is running does not have sufficient permission to access the temp directory. CodeDom will use the user account the process is using to do the compilation, so if the user doesn�t have access to system temp directory, you will not be able to compile. Use Path.GetTempPath() API to find out the temp directory location.*
I used the Path.GetTempPath() as the error says and I am trying to access: >"C:\Users\USERNAME\AppData\Local\Temp\"
I have tried going to these folders and making sure that I have the security set to allow everyone complete control. I believe it is a problem with VS not my program because I get the same problem on all of my programs, some of which I haven't opened in months. I did a repair on VS.
I can't think of what might have changed to cause this to stop working all of a sudden. I traveled to a customers facility where I had to change some network settings, but everything should be set back as it was now. My temporary security certificate expired, but I created a new one and now the certificate I am using to sign these applications is in my trusted root on certificate manager and looks to be valid. I should also mention that this is a clickonce deployment and the deployement works fine on my computer and others, it is only while debugging that I have these issues.
I have been running this down for weeks and spent countless hours looking for a solution and have come to a brick wall. Does anyone have any suggestions?
Thanks ahead of time for your help and time! Please let me know if I can clarify anything.
It turns out that the problem was coming from the fact that somehow one of the folders in the filepath to my user.config file got changed. Somehow a .vshost got thrown in on one of the folder names. I still have no idea how this happened and what caused this to happen, and I am not 100% sure that I have gotten to the real root of the problem, but for now, I am able to debug again. I changed the file name back to what it was supposed to be and the errors have stopped. Now lets just hope the file name doesn't get changed back again.

Resources