title: MSBuild failed at resolving COM reference. Why?
body: <p>My build server suddenly stopped working. After I examined log files I found monster error message:</p>
  
  <pre><code> error MSB4018: The "ResolveComReference" task failed unexpectedly.
   error MSB4018: System.ApplicationException: The directory name is invalid. (Exception from HRESULT: 0x8007010B)
   error MSB4018: 
   error MSB4018: Server stack trace: 
   error MSB4018:    at System.Reflection.Assembly.nDefineVersionInfoResource(String filename, String title, String iconFilename, String description, String copyright, String trademark, String company, String product, String productVersion, String fileVersion, Int32 lcid, Boolean isDll)
   error MSB4018:    at System.Reflection.Emit.AssemblyBuilder.SaveNoLock(String assemblyFileName, PortableExecutableKinds portableExecutableKind, ImageFileMachine imageFileMachine)
   error MSB4018:    at System.Reflection.Emit.AssemblyBuilder.Save(String assemblyFileName, PortableExecutableKinds portableExecutableKind, ImageFileMachine imageFileMachine)
   error MSB4018:    at Microsoft.Build.Tasks.TlbReference.WriteWrapperToDisk(AssemblyBuilder assemblyBuilder, String wrapperPath)
   error MSB4018:    at Microsoft.Build.Tasks.TlbReference.GenerateWrapper(ComReferenceWrapperInfo&amp; wrapperInfo)
   error MSB4018:    at Microsoft.Build.Tasks.ResolveComReference.ResolveComReferenceTlb(ComReferenceInfo referenceInfo, StringoutputDirectory, String refName, Boolean topLevelRef, ComReferenceWrapperInfo&amp; wrapperInfo)
   error MSB4018:    at Microsoft.Build.Tasks.ResolveComReference.ResolveComClassicReference(ComReferenceInfo referenceInfo, String outputDirectory, String wrapperType, String refName, Boolean topLevelRef, ComReferenceWrapperInfo&amp; wrapperInfo)
   error MSB4018:    at Microsoft.Build.Tasks.ResolveComReference.Microsoft.Build.Tasks.IComReferenceResolver.ResolveComClassicReference(TYPELIBATTR typeLibAttr, String outputDirectory, String wrapperType, String refName, ComReferenceWrapperInfo&amp; wrapperInfo)
   error MSB4018:    at Microsoft.Build.Tasks.ResolveComReference.ScanAndResolveAllDependencies(ComDependencyWalker dependencyWalker, ComReferenceInfo reference)
   error MSB4018:    at Microsoft.Build.Tasks.ResolveComReference.ResolveReference(ComDependencyWalker dependencyWalker, ComReferenceInfo referenceInfo, String outputDirectory, ITaskItem&amp; referencePathItem)
   error MSB4018:    at Microsoft.Build.Tasks.ResolveComReference.ResolveReferenceAndAddToList(ComDependencyWalker dependencyWalker, ComReferenceInfo projectRefInfo, ArrayList resolvedReferenceList, ArrayList moduleList)
   error MSB4018:    at Microsoft.Build.Tasks.ResolveComReference.Execute()
   error MSB4018:    at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]&amp; outArgs)
   error MSB4018:    at System.Runtime.Remoting.Messaging.StackBuilderSink.PrivateProcessMessage(RuntimeMethodHandle md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]&amp; outArgs)
   error MSB4018:    at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg, Int32 methodPtr, Boolean fExecuteInContext)
   error MSB4018: 
   error MSB4018: Exception rethrown at [0]: 
   error MSB4018:    at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   error MSB4018:    at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&amp; msgData, Int32 type)
   error MSB4018:    at Microsoft.Build.Framework.ITask.Execute()
   error MSB4018:    at Microsoft.Build.BuildEngine.TaskEngine.ExecuteInstantiatedTask(EngineProxy engineProxy, ItemBucket bucket, TaskExecutionMode howToExecuteTask, ITask task, Boolean&amp; taskResult)
  </code></pre>
  
  <p>All errors are from <code>c:\WINDOWS\Microsoft.NET\Framework\v3.5\Microsoft.Common.targets(1418,9)</code>.</p>
  
  <p>Obviously there are some problems with COM references. I tried reregister all of them but I didn't succeed. </p>
  
  <p>How can I find troubled reference or at least how can I diagnose this problem?</p>
  
  <hr>
  
  <p><strong>Edit</strong>: When I build application locally and copy it to the server it works. So there is problem with something that's needed only for build.</p>