question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

dotnet format 7.0.304 fails when resolving types from COM references

See original GitHub issue

Describe the bug

dotnet format cannot resolve types from COM references

To Reproduce

A trivial test project is available here:

https://github.com/molesmoke/WinFormsAppDotNetFormat

Exceptions (if any)

error CS0246: The type or namespace name 'SpVoice' could not be found (are you missing a using directive or an assembly reference?)

Further technical details

  • Include the output of dotnet --info

.NET SDK: Version: 7.0.304 Commit: 7e794e2806

Runtime Environment: OS Name: Windows OS Version: 10.0.22621 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\7.0.304\

Host: Version: 7.0.7 Architecture: x64 Commit: 5b20af47d9

.NET SDKs installed: 6.0.401 [C:\Program Files\dotnet\sdk] 6.0.402 [C:\Program Files\dotnet\sdk] 6.0.410 [C:\Program Files\dotnet\sdk] 7.0.304 [C:\Program Files\dotnet\sdk] 7.0.400-preview.23274.1 [C:\Program Files\dotnet\sdk]

.NET runtimes installed: Microsoft.AspNetCore.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 6.0.18 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 7.0.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.18 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 7.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 7.0.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 6.0.18 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 7.0.5 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 7.0.7 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found: x86 [C:\Program Files (x86)\dotnet] registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables: Not set

global.json file: C:\Users\jerem\source\repos\tests\WinFormsAppDotNetFormat\global.json

Learn more: https://aka.ms/dotnet/info

Download .NET: https://aka.ms/dotnet/download

  • The IDE (VS / VS Code/ VS4Mac) you’re running on, and its version

Build Tools & VS Pro 17.6.3

Issue Analytics

  • State:open
  • Created 3 months ago
  • Reactions:3
  • Comments:25 (12 by maintainers)

github_iconTop GitHub Comments

2reactions
sharwellcommented, Jun 15, 2023

I’m not sure how/why 7.0.107 worked for this. COMReference isn’t supported for the dotnet tool, which includes dotnet format. https://github.com/dotnet/msbuild/issues/3986

1reaction
sharwellcommented, Jul 21, 2023

Perhaps the generated file isn’t really at that location, but given the analyzer treats/reports it like it is, then I expect that the editorconfig should actually apply.

The tracking issue for this is https://github.com/dotnet/roslyn/issues/47384.

But that’s where VS Pro puts them.

This is also covered in the issue above, e.g. comment https://github.com/dotnet/roslyn/issues/47384#issuecomment-1010270932.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshoot .NET Framework targeting errors
This article provides resolutions for MSBuild errors that might occur because of reference issues.
Read more >
NETSDK1045: The current .NET SDK does not support ...
This error occurs when the build tools can't find the version of the .NET SDK that's needed to build a project. This is...
Read more >
SDK Resolver Failure - Net 7 - Net 6
Try a clean build. When changing Net version the compiler doesn't recognize changes and net and you may still have intermediate obj files...
Read more >
dotnet format command - .NET CLI
The dotnet format command formats code to match EditorConfig settings for the current directory.
Read more >
Microsoft Visual Studio 2019: The project file cannot be ...
I just upgraded my visual studio 2019 to latest version 16.8.3 and suddenly I am not able to load any C# project and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found