Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot resolve dependency to assembly because it has not been preloaded #631

Closed
frarees opened this issue Sep 14, 2020 · 10 comments
Closed

Comments

@frarees
Copy link
Contributor

frarees commented Sep 14, 2020

Log:

VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Apr 12 2020 00:47:07), macOS version

OmniSharp server started.
    Path: /Users/frarees/.cache/omnisharp-vim/omnisharp-roslyn/run
    Target: /Users/frarees/Desktop/test/test.sln
    PID: 12427

[info]: OmniSharp.Stdio.Host
        Starting OmniSharp on MacOS 10.15.6 (x64)
[info]: OmniSharp.Services.DotNetCliService
        DotNetPath set to dotnet
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Located 1 MSBuild instance(s)
            1: StandAlone 16.8.0 - "/Users/frarees/.cache/omnisharp-vim/omnisharp-roslyn/omnisharp/.msbuild/Current/Bin"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        MSBUILD_EXE_PATH environment variable set to '/Users/frarees/.cache/omnisharp-vim/omnisharp-roslyn/omnisharp/.msbuild/Current/Bin/MSBuild.exe'
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Registered MSBuild instance: StandAlone 16.8.0 - "/Users/frarees/.cache/omnisharp-vim/omnisharp-roslyn/omnisharp/.msbuild/Current/Bin"
            CscToolExe = csc.exe
            MSBuildToolsPath = /Users/frarees/.cache/omnisharp-vim/omnisharp-roslyn/omnisharp/.msbuild/Current/Bin
            CscToolPath = /Users/frarees/.cache/omnisharp-vim/omnisharp-roslyn/omnisharp/.msbuild/Current/Bin/Roslyn
            BypassFrameworkInstallChecks = true
            MSBuildExtensionsPath = /Users/frarees/.cache/omnisharp-vim/omnisharp-roslyn/omnisharp/.msbuild
[info]: OmniSharp.Cake.CakeProjectSystem
        Detecting Cake files in '/Users/frarees/Desktop/test'.
[info]: OmniSharp.Cake.CakeProjectSystem
        Could not find any Cake files
[info]: OmniSharp.MSBuild.ProjectSystem
        Detecting projects in '/Users/frarees/Desktop/test/test.sln'.
[info]: OmniSharp.MSBuild.ProjectManager
        Queue project update for '/Users/frarees/Desktop/test/Assembly-CSharp.csproj'
[info]: OmniSharp.Script.ScriptProjectSystem
        Detecting CSX files in '/Users/frarees/Desktop/test'.
[info]: OmniSharp.MSBuild.ProjectManager
        Loading project: /Users/frarees/Desktop/test/Assembly-CSharp.csproj
[info]: OmniSharp.Script.ScriptProjectSystem
        Could not find any CSX files
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpFormattingWorkspaceOptionsProvider, Order: 0
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionOptionsProvider, Order: 0
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.RenameWorkspaceOptionsProvider, Order: 100
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.ImplementTypeWorkspaceOptionsProvider, Order: 110
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.BlockStructureWorkspaceOptionsProvider, Order: 140
[info]: OmniSharp.WorkspaceInitializer
        Configuration finished.
[info]: OmniSharp.Stdio.Host
        Omnisharp server running using Stdio at location '/Users/frarees/Desktop/test' on host -1.
[info]: OmniSharp.OmniSharpWorkspace
        Miscellaneous file: /Users/frarees/Desktop/test/Assets/NewBehaviourScript.cs added to workspace
Replaying requests for buffer 1
[info]: OmniSharp.Roslyn.CSharp.Services.Diagnostics.CSharpDiagnosticWorkerWithAnalyzers
        Solution initialized -> queue all documents for code analysis. Initial document count: 1.
Can't find custom attr constructor image: /Users/frarees/Desktop/test/Library/ScriptAssemblies/Unity.Properties.dll mtoken: 0x0a000005 due to: Cannot resolve dependency to assembly because it has not been preloaded. When using the ReflectionOnly APIs, dependent assemblies must be pre-loaded or loaded on demand through the ReflectionOnlyAssemblyResolve event.
JSON error: Vim(let):E474: Invalid argument
Can't find custom attr constructor image: /Users/frarees/Desktop/test/Library/ScriptAssemblies/UnityEditor.UI.dll mtoken: 0x0a00000b due to: Cannot resolve dependency to assembly because it has not been preloaded. When using the ReflectionOnly APIs, dependent assemblies must be pre-loaded or loaded on demand through the ReflectionOnlyAssemblyResolve event.
JSON error: Vim(let):E474: Invalid argument
3 errors caught while loading: stopping

It happens just on one of my projects, and I cannot seem to figure out where this comes from. Any clue? Thanks!

@nickspoons
Copy link
Member

I don't know what this is sorry, it might be an OmniSharp-roslyn issue, perhaps try to ask there?

I'd recommend getting a raw OmniSharp-roslyn log, by starting the server directly from the command line:

cd /Users/frarees/Desktop/test/
/Users/frarees/.cache/omnisharp-vim/omnisharp-roslyn/run -l debug

@frarees
Copy link
Contributor Author

frarees commented Sep 14, 2020

Cool, will try sharing there. More insights from the OmniSharp-roslyn log.

Can't find custom attr constructor image: /Users/frarees/Desktop/test/Library/ScriptAssemblies/Unity.Properties.dll mtoken: 0x0a000005 due to: Cannot resolve dependency to assembly because it has not been preloaded. When using the ReflectionOnly APIs, dependent assemblies must be pre-loaded or loaded on demand through the ReflectionOnlyAssemblyResolve event.
Can't find custom attr constructor image: /Users/frarees/Desktop/test/Library/ScriptAssemblies/UnityEditor.UI.dll mtoken: 0x0a00000b due to: Cannot resolve dependency to assembly because it has not been preloaded. When using the ReflectionOnly APIs, dependent assemblies must be pre-loaded or loaded on demand through the ReflectionOnlyAssemblyResolve event.
Can't find custom attr constructor image: /Users/frarees/Desktop/test/Library/ScriptAssemblies/Unity.Properties.dll mtoken: 0x0a000005 due to: Cannot resolve dependency to assembly because it has not been preloaded. When using the ReflectionOnly APIs, dependent assemblies must be pre-loaded or loaded on demand through the ReflectionOnlyAssemblyResolve event.
Can't find custom attr constructor image: /Users/frarees/Desktop/test/Library/ScriptAssemblies/UnityEditor.UI.dll mtoken: 0x0a00000b due to: Cannot resolve dependency to assembly because it has not been preloaded. When using the ReflectionOnly APIs, dependent assemblies must be pre-loaded or loaded on demand through the ReflectionOnlyAssemblyResolve event.

Also:

{"Event":"log","Body":{"LogLevel":"ERROR","Name":"OmniSharp.MSBuild.ProjectLoadListener","Message":"Unexpected exception got thrown from project load listener: System.NullReferenceException: Object reference not set to an instance of an object\n  at OmniSharp.MSBuild.ProjectLoadListener.GetSdkVersion (OmniSharp.MSBuild.Notification.ProjectLoadedEventArgs args) [0x0000b] in <7e6cb753aca94549b693616e0e7d1016>:0 \n  at OmniSharp.MSBuild.ProjectLoadListener.ProjectLoaded (OmniSharp.MSBuild.Notification.ProjectLoadedEventArgs args) [0x0001a] in <7e6cb753aca94549b693616e0e7d1016>:0 "},"Seq":582,"Type":"event"}

@nickspoons
Copy link
Member

Yeah that NullReferenceException is certainly happening on the OmniSharp-roslyn side

@frarees
Copy link
Contributor Author

frarees commented Sep 15, 2020

I've seen that the NullReferenceException is happening on other projects that I can open successfully, so might not be related.

Aside, since I get more than 3 errors (4 Can't find custom attr constructor image errors), it warns me that I might be using the HTTP version.

You appear to be running an HTTP server in stdio mode - upgrade to the stdio server with :OmniSharpInstall, or to continue  in HTTP mode add the following to your .vimrc and restart Vim:   let g:OmniSharp_server_stdio = 0
channel 0 closed: '<feff>'

Maybe there's a way to gracefully ignore these?

The project actually loads, so I'm wondering if omnisharp-vim is stopping cause it's getting these unknown errors, but could actually continue to function.

...
{"Event":"log","Body":{"LogLevel":"INFORMATION","Name":"OmniSharp.MSBuild.ProjectManager","Message":"Successfully loaded project file '/Users/frarees/Desktop/test/Assembly-CSharp.csproj'."},"Seq":50,"Type":"event"}
{"Event":"MsBuildProjectDiagnostics","Body":{"FileName":"/Users/frarees/Desktop/test/Assembly-CSharp.csproj","Warnings":[],"Errors":[]},"Seq":51,"Type":"event"}
{"Event":"log","Body":{"LogLevel":"INFORMATION","Name":"OmniSharp.MSBuild.ProjectManager","Message":"Adding project '/Users/frarees/Desktop/test/Assembly-CSharp.csproj'"},"Seq":52,"Type":"event"}
{"Event":"log","Body":{"LogLevel":"INFORMATION","Name":"OmniSharp.MSBuild.ProjectManager","Message":"Update project: Assembly-CSharp"},"Seq":53,"Type":"event"}
...

@nickspoons
Copy link
Member

Maybe there's a way to gracefully ignore these?

The project actually loads, so I'm wondering if omnisharp-vim is stopping cause it's getting these unknown errors, but could actually continue to function.

Hmm, you may be right about that. Do you want to test this out? You could try changing the 3 here to e.g. 100: https://github.com/OmniSharp/omnisharp-vim/blob/master/autoload/OmniSharp/stdio.vim#L15

@frarees
Copy link
Contributor Author

frarees commented Sep 15, 2020

Indeed, it worked!

@nickspoons
Copy link
Member

Well, just increasing that limit is a pretty simple fix. I don't know what a sensible number of json errors to receive is? I do still want to have this test, as it is a reasonably reliable way to detect that the user is using the HTTP version of the server.

Or perhaps instead of just counting invalid json messages from the server, we could count both valid and invalid, and just check that there are more valid than invalid messages. That seems a bit more robust.

@frarees
Copy link
Contributor Author

frarees commented Sep 15, 2020

Or perhaps instead of just counting invalid json messages from the server, we could count both valid and invalid, and just check that there are more valid than invalid messages.

Sounds like a good idea. I guess a message being valid is a greater indicator than a message being invalid. Is it easy to have successful messages when missmatching stdio/http? If it's not easy, what about waiting for n messages and check how many of them are successful? e.g. wait until you get 6 messages, check that 3 of them are valid.

@nickspoons
Copy link
Member

@frarees could you give the latest version a try?

@frarees
Copy link
Contributor Author

frarees commented Sep 15, 2020

All good 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants