This project is read-only.

[...]COMException (0x80004005): Error HRESULT E_FAIL has been returned [...]

Oct 31, 2011 at 7:50 PM

After many months (years?!) of thinking about migrating from VSS to SVN, I finally decided to "bite the bullet", so to speak, and give it a try (it helped that I recently installed VS2010, since I couldn't compile the project under VS2005 :-)

After reading a bunch of pages (and in particular this article: http://devsolo.com/index.php/2009/05/migrating-visual-sourcesafe-to-subversion/) I managed to install SVN on my machine (VisualSVN), create my first repository, and begin the process of migrating! Things were going well until suddenly, and inexplicably, VSSMigrate threw this error:

System.Runtime.InteropServices.COMException (0x80004005): Error HRESULT E_FAIL has been returned from a call to a COM component.

I discovered it only occurred for certain projects, so I decided it was time to test my C# debugging skills (being a C++ programmer :-).

A couple of breakpoints later and I discovered that the error was occurring during a call to "BuildRevisionList(IVSSItem item)". Digging deeper, the error was occurring during the comparison:

if (version == versions[versions.Count - 1])

The array contained a valid number of references, but then I realised that not all of the objects themselves were valid. Checking back in the original VSS repository I found that the item in question had actually been deleted, but not purged. After restoring the item, I was able to confirm that the number of history versions was correct. However, what I also noticed was that all but the first item were actually labels. A quick solution to this problem, therefore, is to add the following extra case statement:

case 0x80004005: //version is (probably!) a label, but the original item has been deleted.
	if (version.VSSItem.Deleted)
	{
		searchLog.WarnFormat("Skipping version (LABEL) because this item has been deleted.");
		continue;
	}
	// If the item was NOT deleted, the error probably indicates some other problem. Pass is back to the user.
	throw;

At least in my case (so far!), this has allowed me to export several projects which included deleted, but not purged, items. I'm not sure if there is a better way to do this (I've never used the VSS API), or even if this error might occur for other reasons, but at least it might help others get their projects migrated.

John

 


Nov 7, 2011 at 7:11 PM
Edited Nov 7, 2011 at 7:20 PM

You might try repairing your SourceSafe database to remove corruption, if you come across that. The link points to the post I just made how to do that.

This link says how to purge those files.  If you don't want to purge them from the main SourceSafe repository, just copy the repository to a temporary location elsewhere.  Then purge and migrate there.

Nov 16, 2011 at 12:49 PM

Thanks for the replies and the links. Purging is an option I suppose. However, purging also means losing the history (and access) to those purged items from earlier versions.

Over the last few days I've made a few modifications to the original source, including better handling of deleted (but not purged) items, and the ability to migrate projects from the top down (with the current version, each VSS subfolder has to be imported before its parent folder, a painful process when the number of projects is large and/or the tree is deep!) When I have a moment (and when I figure out how!) I'll upload my changes for other to make use of.

Jan 18, 2012 at 6:41 AM
I have migrate project successfully but in case of deleted file it is showing above error. i have used this code .
private static void BuildRevisionList(IVSSItem item)
{
IVSSVersions versions = item.get_Versions(0);
foreach (IVSSVersion version in versions)
{
try
{

if (version.VSSItem.Deleted)
{
// if (version == versions[versions.Count - 1])
// {
AddRevision(version, true);
// }
}

if (item.Type == (int) VSSItemType.VSSITEM_PROJECT)
{
//if (projList.Exists(proj => string.Compare(proj.Spec, item.Spec, true) == 0))
//{
// migrateLog.Debug(item.Spec + " already exists!");
// continue;
//}
projList.Add(item);
}

AddRevision(version,false);
}
catch (COMException ex)
{
switch ((uint) ex.ErrorCode)
{
case 0x80040000: //version is corrupted and unavailable
searchLog.WarnFormat(
"Skipping version due to corruption {0} in file {1} [cannot read resource]",
version.VersionNumber, item.Spec);
continue;
case 0x8004D68F: //file not found
searchLog.WarnFormat("Skipping version due to corruption {0} in file {1} [file not found]",
version.VersionNumber, item.Spec);
continue;
default:
throw;
}
}
}
}
but it didnt work showing error. please can any one help me.
I have used Sourcesafetypelib but this lib won't work for this code
if (version == versions[versions.Count - 1]) as count need Interrop.SourcesafeTypelib
I am using vss6.0 thanx in advance.............