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

Impossible is possible so we need a message #2162

Closed
moozzyk opened this issue Jul 1, 2015 · 6 comments
Closed

Impossible is possible so we need a message #2162

moozzyk opened this issue Jul 1, 2015 · 6 comments
Assignees
Milestone

Comments

@moozzyk
Copy link
Contributor

moozzyk commented Jul 1, 2015

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.

@davidfowl
Copy link
Member

This is actually a known issue see https://github.com/aspnet/Tooling-Internal/issues/291

@moozzyk
Copy link
Contributor Author

moozzyk commented Jul 1, 2015

@davidfowl - yes but at the moment if a user ends up in a limbo like this there are no hints how to get out of it. Adding a message could be a stop gap until VS can somehow handle this.

@muratg
Copy link
Contributor

muratg commented Jul 1, 2015

Feel like we should add a message to the IOE. Is this the only case where that can be thrown?

(Also should remove that comment 😄)

@muratg
Copy link
Contributor

muratg commented Jul 6, 2015

cc @troydai

@troydai
Copy link
Contributor

troydai commented Jul 6, 2015

I'm sure there is other way to trick DNX to run into this situation. We should add a message.

@troydai
Copy link
Contributor

troydai commented Jul 23, 2015

Fixed in 587a4a5

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

No branches or pull requests

4 participants