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

Stack traces for Roslyn compilation errors aren't supressed #2887

Closed
shirhatti opened this issue Oct 1, 2015 · 3 comments
Closed

Stack traces for Roslyn compilation errors aren't supressed #2887

shirhatti opened this issue Oct 1, 2015 · 3 comments
Assignees
Milestone

Comments

@shirhatti
Copy link

C:\Users\vagrant\Documents\Visual Studio 2015\Projects\ConsoleApp1\src\ConsoleApp1> dnx ConsoleApp1 test
Microsoft.Dnx.Compilation.CSharp.RoslynCompilationException: C:\Users\vagrant\Documents\Visual Studio 2015\Projects\ConsoleApp1\src\ConsoleApp1\Program.cs(14,17): DNXCore,Version=v5.0 error CS0234: The type or namespace name 'Console' does not exist in the namespace 'System' (are you missing an assembly reference?)
   at Microsoft.Dnx.Compilation.CSharp.RoslynProjectReference.Load(AssemblyName assemblyName, IAssemblyLoadContext loadContext)
   at Microsoft.Dnx.Compilation.CompilationEngine.LoadProject(Project project, FrameworkName targetFramework, String aspect, IAssemblyLoadContext loadContext, AssemblyName assemblyName)
   at Microsoft.Dnx.Runtime.Loader.ProjectAssemblyLoader.Load(AssemblyName assemblyName, IAssemblyLoadContext loadContext)
   at Microsoft.Dnx.Runtime.Loader.ProjectAssemblyLoader.Load(AssemblyName assemblyName)
   at Microsoft.Dnx.Host.LoaderContainer.Load(AssemblyName assemblyName)
   at Microsoft.Dnx.Host.DefaultLoadContext.LoadAssembly(AssemblyName assemblyName)
   at Microsoft.Dnx.Runtime.Loader.AssemblyLoaderCache.GetOrAdd(AssemblyName name, Func`2 factory)
   at Microsoft.Dnx.Runtime.Loader.LoadContext.Load(AssemblyName assemblyName)
   at System.Runtime.Loader.AssemblyLoadContext.LoadFromAssemblyName(AssemblyName assemblyName)
   at Microsoft.Dnx.Runtime.Loader.LoadContext.Microsoft.Dnx.Runtime.IAssemblyLoadContext.Load(AssemblyName assemblyName)
   at Microsoft.Dnx.ApplicationHost.DefaultHost.GetEntryPoint(String applicationName)
   at Microsoft.Dnx.ApplicationHost.Program.ExecuteMain(DefaultHost host, String applicationName, String[] args)
   at Microsoft.Dnx.ApplicationHost.Program.Main(String[] args)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.Dnx.Runtime.Common.EntryPointExecutor.Execute(Assembly assembly, String[] args, IServiceProvider serviceProvider)
   at Microsoft.Dnx.Host.Bootstrapper.RunAsync(List`1 args, IRuntimeEnvironment env, String appBase, FrameworkName targetFramework)
   at Microsoft.Dnx.Host.RuntimeBootstrapper.ExecuteAsync(String[] args, BootstrapperContext bootstrapperContext)
   at Microsoft.Dnx.Host.RuntimeBootstrapper.Execute(String[] args, BootstrapperContext bootstrapperContext)

cc @JunTaoLuo

@JunTaoLuo
Copy link
Contributor

Related to #2853

The issue is Microsoft.Dnx.ApplicationHost/Program.cs#L234 where we only suppress ICompilationExceptions if they are wrapped by FileLoadException or FileNotFoundException. In this case when the assembly was not found, the outer exception was the ICompilationExceptions.

What we need is something like

catch (Exception ex)
{
    if (ex is ICompilationException)
    {
        throw SuppressStackTrace(ex);
    }

    if (ex.InnerException is ICompilationException)
    {
        throw SuppressStackTrace(ex.InnerException);
    }

    if (ex is FileLoadException || ex is FileNotFoundException)
    {
        ThrowEntryPointNotfoundException(
            host,
            applicationName,
            ex.InnerException);
    }

    throw;
}

@JunTaoLuo JunTaoLuo added the bug label Oct 2, 2015
@JunTaoLuo JunTaoLuo added this to the 1.0.0-rc1 milestone Oct 2, 2015
@pranavkm
Copy link
Contributor

pranavkm commented Oct 2, 2015

👍

@pakrym
Copy link
Contributor

pakrym commented Oct 12, 2015

We also need to suppress exceptions coming from ExecuteMain (see comments from #2928).

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