1

I'm trying to add and use shell32.dll to my console project in VS Code. I put it to root folder of project, ..\bin and ..\bin\Debug. I made dotnet restore. Code in my .csproj file is:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp3.1</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="Shell32">
      <HintPath>shell32.dll</HintPath>
      <SpecificVersion>False</SpecificVersion>
    </Reference>
  </ItemGroup>
</Project>

But when I add using Shell32; to Program.cs it is giving error "The type or namespace name 'Shell32' could not be found". Please advise what am I doing wrong?

EylM
  • 5,967
  • 2
  • 16
  • 28
Dork
  • 1,816
  • 9
  • 29
  • 57

1 Answers1

0

You the COM reference to add Microsoft Shell Controls and Automation instead of referencing the actuall Shell32.dll.

Sample XML:

<ItemGroup>
    <COMReference Include="Shell32.dll">
      <Guid>50a7e9b0-70ef-11d1-b75a-00a0c90564fe</Guid>
      <VersionMajor>1</VersionMajor>
      <VersionMinor>0</VersionMinor>
      <WrapperTool>tlbimp</WrapperTool>
      <Lcid>0</Lcid>
      <Isolated>false</Isolated>
    </COMReference>
  </ItemGroup>
EylM
  • 5,967
  • 2
  • 16
  • 28