Skip to content
This repository was archived by the owner on Dec 18, 2017. It is now read-only.
This repository was archived by the owner on Dec 18, 2017. It is now read-only.

Impossible is possible so we need a message #2162

Closed
@moozzyk

Description

@moozzyk

Depspite the "this should never happen" comment this code:

// This should never happen
throw new InvalidOperationException();

may throw which results in a YSOD that is not giving any hints to the user what went wrong. There are no errors in VS whatsoever as well but you just can not make the application work/run. This is what you will see if the exception is thrown:

Server Error in '/' Application.

Operation is not valid due to the current state of the object.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.InvalidOperationException: Operation is not valid due to the current state of the object.

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace: 

[InvalidOperationException: Operation is not valid due to the current state of the object.]

[AggregateException: One or more errors occurred.]

[FileLoadException: Could not load file or assembly 'Microsoft.AspNet.Loader.IIS' or one of its dependencies. General Exception (Exception from HRESULT: 0x80131500)]

[TargetInvocationException: Exception has been thrown by the target of an invocation.]
   System.Web.HttpRuntime.HostingInit(HostingEnvironmentFlags hostingFlags, PolicyLevel policyLevel, Exception appDomainCreationException) +303

[HttpException (0x80004005): Exception has been thrown by the target of an invocation.]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9924184
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +261

TL;DR;

This happens if there are multiple global.json files in the solution. For instance you add another project/folder that has a global.json file. In this case VS may spin multiple dnx instance/DTH hosts if the global.json files contain different sdk versions, or if some global.json files don't contain sdk version at all in which case VS will default to use the runtime aliased by default. In case of the runtime mismatch when a user press F5/Ctrl+F5 VS will try compiling subprojects using DTH corresponding to the runtime which will basically always fail since the solution will be split and dependencies will be missing. There is nothing in VS that indicates the version mismatch so it is close to impossible for the user to figure out what's going on (at least it took me and @troydai a considerable amount of time to figure this out). I talked to @PradeepKadubandi and this is the know behavior/issue but it has not been addressed so far. We agreed that even though fixing this for ther user can be hard or impossible in some cases (multiple projects using different runtimes referencing the same project) an actionable warning/visual cue would help the user understand the problem (and fix on their side) or at least make it possible to search for a solution. DTH however could actually help the user as well by throwing an exception with a message recommending checking that if the user has multiple global.json files all the versions are aligned.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions