ProjectReference to a Project with TargetType=module crashes VS
See original GitHub issue- Create a Project with
TargetType=module
ProjectReference
it from another project- Open the projects from VS.
Observed: VS will crash.
$exception
{"Can't create a reference to a module."}
Data: {System.Collections.ListDictionaryInternal}
HResult: -2146233067
HelpLink: null
IPForWatsonBuckets: 0x2a586a41
InnerException: null
IsTransient: false
Message: "Can't create a reference to a module."
RemoteStackTrace: null
Source: "Microsoft.CodeAnalysis"
StackTrace: " at Microsoft.CodeAnalysis.CompilationReference.GetProperties(Compilation compilation, ImmutableArray`1 aliases, Boolean embedInteropTypes)\r\n at Microsoft.CodeAnalysis.CSharp.CSharpCompilation.ToMetadataReference(ImmutableArray`1 aliases, Boolean embedInteropTypes)\r\n at Microsoft.CodeAnalysis.SolutionState.CompilationTracker.<GetMetadataReferenceAsync>d__32.MoveNext() in /_/src/Workspaces/Core/Portable/Workspace/Solution/SolutionState.CompilationTracker.cs:line 707"
TargetSite: {Microsoft.CodeAnalysis.MetadataReferenceProperties GetProperties(Microsoft.CodeAnalysis.Compilation, System.Collections.Immutable.ImmutableArray`1[System.String], Boolean)}
WatsonBuckets: null
_HResult: -2146233067
_className: "System.NotSupportedException"
_data: {System.Collections.ListDictionaryInternal}
_dynamicMethods: null
_exceptionMethod: null
_exceptionMethodString: null
_helpURL: null
_innerException: null
_ipForWatsonBuckets: 0x2a586a41
_message: "Can't create a reference to a module."
_remoteStackIndex: 0
_remoteStackTraceString: null
_safeSerializationManager: {System.Runtime.Serialization.SafeSerializationManager}
_source: null
_stackTrace: {sbyte[96]}
_stackTraceString: null
_watsonBuckets: null
_xcode: -532462766
_xptrs: 0x00000000
"System.NotSupportedException: Can't create a reference to a module
at Microsoft.CodeAnalysis.CompilationReference.GetProperties(Compilation compilation, ImmutableArray`1 aliases, Boolean embedInteropTypes)
at Microsoft.CodeAnalysis.CSharp.CSharpCompilation.ToMetadataReference(ImmutableArray`1 aliases, Boolean embedInteropTypes)
at Microsoft.CodeAnalysis.SolutionState.CompilationTracker.<GetMetadataReferenceAsync>d__32.MoveNext() in /_/src/Workspaces/Core/Portable/Workspace/Solution/SolutionState.CompilationTracker.cs:line 707"
This is what I’m seeing in CompilationReference.cs
:
internal static MetadataReferenceProperties GetProperties(Compilation compilation, ImmutableArray<string> aliases, bool embedInteropTypes)
{
if (compilation == null)
{
throw new ArgumentNullException(nameof(compilation));
}
if (compilation.IsSubmission)
{
throw new NotSupportedException(CodeAnalysisResources.CannotCreateReferenceToSubmission);
}
if (compilation.Options.OutputKind == OutputKind.NetModule)
{
throw new NotSupportedException(CodeAnalysisResources.CannotCreateReferenceToModule);
}
return new MetadataReferenceProperties(MetadataImageKind.Assembly, aliases, embedInteropTypes);
}
dotnet/wpf repo is planning on using netmodules it as part of product-binaries, and this would imply that the solution in the repo can not be used/built in VS. It would be great if netmodule-references can be supported in Dev16.4.
/cc @rladuca /cc @tgani-msft, @dotnet/wpf-developers
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (5 by maintainers)
Top Results From Across the Web
vs 2017 crashes when adding reference to project
VS 2017 often crashes when adding a reference to a project. Steps to produce: 1. open project references node.
Read more >Visual Studio crashes on 'add reference'
Visual Studio crashes when opening any solution and right-clicking 'references' and choosing 'add reference'. The dialog opens for a few seconds ...
Read more >Manage references in a project - Visual Studio (Windows)
Learn how to manage references to external components and connected services in a project.
Read more >What is Project to Project reference & why is it needed
Understand C# project to project reference, and the benefits.
Read more >Project References - TypeScript: Documentation
Project references are a new feature in TypeScript 3.0 that allow you to structure your TypeScript programs into smaller pieces.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Note that reference is marked as:
Which should mean that it isn’t passed as reference, so we have a couple of bugs:
ReferenceOutputAssembly
ReferenceOutputAssembly
is specified.Probably a combination of Roslyn, Project and MSBuild bugs.
What’s the expectation here? Clearly we should do better than a crash - but a reference to a module isn’t valid.