Error HRESULT E_FAIL has been returned from a call to a COM component

Soumabha Sarkar 41 Reputation points
2022-05-23T12:15:45.69+00:00

We are distributing one dll along with our extension which is present in location once the extension is installed. We need to implement a functionality where this dll has to be added in the reference when a generate a custom class to any console/winform project. We tried to use VSLangProj.References.Add("xyz.dll") but we are getting exception

Error HRESULT E_FAIL has been returned from a call to a COM component
at VSLangProj.References.Add(String bstrPath)

According to the MS documentation, (https://learn.microsoft.com/en-us/dotnet/api/vslangproj.references.add?view=visualstudiosdk-2022#vslangproj-references-add(system-string))

The development environment searches for the name in the following order, stopping as soon as a match is found:

In the project hierarchy.

In the references search path, which is a project-level setting. For more information, see ReferencePath.

In the set of directories the component picker uses when enumerating references. This set of directories is stored in the registry during installation.

Each reference is resolved when a project is loaded. Resolution also occurs on a new reference when the bstrPath parameter to the Add method is something other than a full path.

We have made entry for this dll in the pkgdef file

[$RootKey$\RuntimeConfiguration\dependentAssembly\codeBase{GUID}]
"name"="xyz"
"publicKeyToken"="12ab"
"culture"="neutral"
"version"="1.1.1.1"
"codeBase"="$PackageFolder$\Assemblies\Providers\xyz.dll"

Not Monitored
Not Monitored
Tag not monitored by Microsoft.
35,997 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Rifka 0 Reputation points
    2023-03-16T09:27:46.5666667+00:00
    
    
    please can you help me? how to fix this, my VS is a new version.