Skip to content

"Object reference not set to an instance of an object" when trying to run a "hello world" type of application from a fresh "cargo new"Β #55

@JohnstonJ

Description

@JohnstonJ

Using Visual Studio 2022 Community (latest version):

  1. Run cargo new vstest to create a new template application.
  2. Open the folder in Visual Studio.
  3. At the run toolbar at the top, choose the [bin: \] vstest.exe and dev target.
  4. Click Debug menu, and then Start Without Debugging.

The EXE file is then built as expected.... but it fails to subsequently run, giving an error Object reference not set to an instance of an object.:

image

Build log:

==== Build step: Started ====
        Using : cargo 1.81.0 (2dbb1af80 2024-08-20)
        Using : rustc 1.81.0 (eeb90cda1 2024-09-04)
         Path : C:\Users\vagrant\.cargo\bin\cargo.exe
    Arguments : build --manifest-path "C:\Users\vagrant\Documents\testing\vstest\Cargo.toml" --profile dev --message-format json 
   WorkingDir : C:\Users\vagrant\Documents\testing\vstest
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.00s
==== Build step: Finished ====

rust-analyzer.vs log:

240913.23.44.23.199 - Creating FileScannerFactory.
240913.23.44.23.214 - Creating MDS. Workspace root: C:\Users\vagrant\Documents\testing\vstest.
240913.23.44.23.591 - GetContainingPackageAsync. File path: C:\Users\vagrant\Documents\testing\vstest\src\main.rs.
240913.23.44.23.591 - GetContainingPackageAsync. File path: C:\Users\vagrant\Documents\testing\vstest\Cargo.toml.
240913.23.44.23.591 - GetPackageAsync. Manifest path: C:\Users\vagrant\Documents\testing\vstest\Cargo.toml.
240913.23.44.23.591 - GetPackageAsync. Manifest path: C:\Users\vagrant\Documents\testing\vstest\Cargo.toml.
240913.23.44.23.591 - ... Cache miss: C:\Users\vagrant\Documents\testing\vstest\Cargo.toml.
240913.23.44.23.591 - ... using cargo.exe from 'C:\Users\vagrant\.cargo\bin\cargo.exe'.
240913.23.44.23.591 - GetContainingPackageAsync. File path: C:\Users\vagrant\Documents\testing\vstest\Cargo.toml.
240913.23.44.23.591 - GetPackageAsync. Manifest path: C:\Users\vagrant\Documents\testing\vstest\Cargo.toml.
240913.23.44.23.591 - GetContainingPackageAsync. File path: C:\Users\vagrant\Documents\testing\vstest\src\main.rs.
240913.23.44.23.591 - GetPackageAsync. Manifest path: C:\Users\vagrant\Documents\testing\vstest\Cargo.toml.
240913.23.44.23.591 - Started PID:1872 with args: C:\Users\vagrant\.cargo\bin\cargo.exe metadata --no-deps --format-version 1 --manifest-path C:\Users\vagrant\Documents\testing\vstest\Cargo.toml --offline...
240913.23.44.23.607 - ... Finished PID 1872 with exit code 0.
240913.23.44.24.321 - Attempting to show release notes...
240913.23.44.24.321 - ... Not showing release notes as it has already been dismissed by the user.
240913.23.44.24.321 - Searching and disabling incompatible extensions.
240913.23.44.24.731 - Running PreReqCheck: VsVersionCheck...
240913.23.44.24.793 - Running PreReqCheck: CheckRustupAsync...
240913.23.44.24.793 - Running PreReqCheck: CheckCargoAsync...
240913.23.44.24.793 - ... using cargo.exe from 'C:\Users\vagrant\.cargo\bin\cargo.exe'.
240913.23.44.24.808 - Initiating download of RLS...
240913.23.44.25.168 - Not going to download RLS. Installed = 2024-09-09, Latest = https://github.com/rust-lang/rust-analyzer/releases/download/2024-09-09/rust-analyzer-x86_64-pc-windows-msvc.zip.
240913.23.44.35.108 - GetContainingPackageAsync. File path: C:\Users\vagrant\Documents\testing\vstest\Cargo.toml.
240913.23.44.35.108 - GetPackageAsync. Manifest path: C:\Users\vagrant\Documents\testing\vstest\Cargo.toml.
240913.23.44.35.156 - Creating FileContextProviderFactory.
240913.23.44.35.156 - GetContainingPackageAsync. File path: C:\Users\vagrant\Documents\testing\vstest\Cargo.toml.
240913.23.44.35.156 - GetPackageAsync. Manifest path: C:\Users\vagrant\Documents\testing\vstest\Cargo.toml.
240913.23.44.35.246 - GetContainingPackageAsync. File path: C:\Users\vagrant\Documents\testing\vstest\Cargo.toml.
240913.23.44.35.246 - GetPackageAsync. Manifest path: C:\Users\vagrant\Documents\testing\vstest\Cargo.toml.
240913.23.44.46.251 - ... using cargo.exe from 'C:\Users\vagrant\.cargo\bin\cargo.exe'.
240913.23.44.47.934 - CargoJsonOutputParser failed to parse line: {"reason":"compiler-artifact","package_id":"path+file:///C:/Users/vagrant/Documents/testing/vstest#0.1.0","manifest_path":"C:\\Users\\vagrant\\Documents\\testing\\vstest\\Cargo.toml","target":{"kind":["bin"],"crate_types":["bin"],"name":"vstest","src_path":"C:\\Users\\vagrant\\Documents\\testing\\vstest\\src/main.rs","edition":"2021","doc":true,"doctest":false,"test":true},"profile":{"opt_level":"0","debuginfo":2,"debug_assertions":true,"overflow_checks":true,"test":false},"features":[],"filenames":["C:\\Users\\vagrant\\Documents\\testing\\vstest\\target\\debug\\vstest.exe","C:\\Users\\vagrant\\Documents\\testing\\vstest\\target\\debug\\vstest.pdb"],"executable":"C:\\Users\\vagrant\\Documents\\testing\\vstest\\target\\debug\\vstest.exe","fresh":false}. Exception System.IO.InvalidDataException: Unable to match. Will be shown as is in the output window.
   at KS.RustAnalyzer.TestAdapter.Cargo.BuildJsonOutputParser.ParseCompilerArtifact(Object obj) in D:\a\rust-analyzer.vs\rust-analyzer.vs\src\RustAnalyzer.TestAdapter\Cargo\BuildJsonOutputParser.cs:line 166
   at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1)
   at KS.RustAnalyzer.TestAdapter.Cargo.BuildJsonOutputParser.Parse(PathEx workspaceRoot, String jsonLine, TL tl) in D:\a\rust-analyzer.vs\rust-analyzer.vs\src\RustAnalyzer.TestAdapter\Cargo\BuildJsonOutputParser.cs:line 54.
240913.23.44.48.012 - ... using cargo.exe from 'C:\Users\vagrant\.cargo\bin\cargo.exe'.
240913.23.44.48.012 - Started PID:3712 with args: C:\Users\vagrant\.cargo\bin\cargo.exe metadata --no-deps --format-version 1 --manifest-path C:\Users\vagrant\Documents\testing\vstest\Cargo.toml --offline...
240913.23.44.48.121 - ... Finished PID 3712 with exit code 0.
240913.23.44.48.152 - GetContainingPackageAsync. File path: C:\Users\vagrant\Documents\testing\vstest\Cargo.toml.
240913.23.44.48.152 - GetPackageAsync. Manifest path: C:\Users\vagrant\Documents\testing\vstest\Cargo.toml.
240913.23.44.48.152 - LaunchDebugTarget with profile: dev, launchConfiguration: {}
240913.23.50.00.683 - ... using cargo.exe from 'C:\Users\vagrant\.cargo\bin\cargo.exe'.
240913.23.50.01.043 - ... using cargo.exe from 'C:\Users\vagrant\.cargo\bin\cargo.exe'.
240913.23.50.01.043 - Started PID:7148 with args: C:\Users\vagrant\.cargo\bin\cargo.exe metadata --no-deps --format-version 1 --manifest-path C:\Users\vagrant\Documents\testing\vstest\Cargo.toml --offline...
240913.23.50.01.152 - ... Finished PID 7148 with exit code 0.
240913.23.50.01.152 - GetContainingPackageAsync. File path: C:\Users\vagrant\Documents\testing\vstest\Cargo.toml.
240913.23.50.01.152 - GetPackageAsync. Manifest path: C:\Users\vagrant\Documents\testing\vstest\Cargo.toml.
240913.23.50.01.152 - LaunchDebugTarget with profile: dev, launchConfiguration: {}
240913.23.50.18.715 - ... using cargo.exe from 'C:\Users\vagrant\.cargo\bin\cargo.exe'.
240913.23.50.19.027 - ... using cargo.exe from 'C:\Users\vagrant\.cargo\bin\cargo.exe'.
240913.23.50.19.027 - Started PID:4632 with args: C:\Users\vagrant\.cargo\bin\cargo.exe metadata --no-deps --format-version 1 --manifest-path C:\Users\vagrant\Documents\testing\vstest\Cargo.toml --offline...
240913.23.50.19.121 - ... Finished PID 4632 with exit code 0.
240913.23.50.19.121 - GetContainingPackageAsync. File path: C:\Users\vagrant\Documents\testing\vstest\Cargo.toml.
240913.23.50.19.121 - GetPackageAsync. Manifest path: C:\Users\vagrant\Documents\testing\vstest\Cargo.toml.
240913.23.50.19.121 - LaunchDebugTarget with profile: dev, launchConfiguration: {}

Here is the cargo.toml file - this is just as-is from cargo new:

[package]
name = "vstest"
version = "0.1.0"
edition = "2021"

[dependencies]

This issue would seem to block me from using this extension for any real practical use, if I can't run the program.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions