TargetType=moduleProjectReference it from another projectObserved: 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:
```C#
internal static MetadataReferenceProperties GetProperties(Compilation compilation, ImmutableArray
{
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
who're working on the project system support for C++/CLI for .NET Core.
/cc @olgaark, @nguerrera
Is this a project system issue? The code in question is part of Roslyn:
What's the expectation here? Clearly we should do better than a crash - but a reference to a module isn't valid.
What's the expectation here? Clearly we should do better than a crash - but a reference to a module isn't valid.
The attached repro project contains a ProjectReference to a project that produces a module, but it doesn't _reference_ module. i.e., there is no (illegal) reference to the module.
Maybe the issue is that VS is is unable to see the the distinction that a ProjectReferencedoesn't always imply that there will be a reference to the projects's outputs?
Note that reference is marked as:
<ProjectReference Include="..\module\module.csproj">
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
<OutputItemType>AddModules</OutputItemType>
</ProjectReference>
Which should mean that it isn't passed as reference, so we have a couple of bugs:
1) We shouldn't crash if someone doesn't specify ReferenceOutputAssembly
2) We shouldn't be passing this module to Roslyn when ReferenceOutputAssembly is specified.
Probably a combination of Roslyn, Project and MSBuild bugs.
Most helpful comment
Note that reference is marked as:
Which should mean that it isn't passed as reference, so we have a couple of bugs:
1) We shouldn't crash if someone doesn't specify
ReferenceOutputAssembly2) We shouldn't be passing this module to Roslyn when
ReferenceOutputAssemblyis specified.Probably a combination of Roslyn, Project and MSBuild bugs.