Я играю вокруг новой бета-версии ASPNET 5, используя последнюю версию Visual Studio Code (v0.3). Я не хочу ставить VS2015 RC на свою рабочую машину. У меня есть barebone (Hello World) MVC6-приложение, которое я запускал после выяснения основ инструментов командной строки dn *.
Теперь я хочу служить статическому файлу. Я добавил файл Microsoft.AspNet.StaticFiles в файл project.json и восстановил пакеты.
Мой проект .json:
{
"version": "1.0.0-*",
"webroot": "wwwroot",
"exclude": [
"wwwroot"
],
"packExclude": [
"**.kproj",
"**.user",
"**.vspscc"
],
"dependencies": {
"Kestrel": "1.0.0-*",
"Microsoft.AspNet.Diagnostics": "1.0.0-*",
"Microsoft.AspNet.Mvc": "6.0.0-*",
"Microsoft.AspNet.Server.IIS": "1.0.0-*",
"Microsoft.AspNet.Server.WebListener": "1.0.0-*",
"Microsoft.AspNet.StaticFiles": "1.0.0-*"
},
"commands": {
"web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --server.urls http://localhost:8080",
"kestrel": "Microsoft.AspNet.Hosting --server Kestrel --server.urls http://localhost:8080"
},
"frameworks": {
"dnx451": { },
"dnxcore50": { }
}
}
My Startup.cs:
using Microsoft.AspNet.Builder;
using Microsoft.Framework.DependencyInjection;
namespace EmailViewer
{
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
}
public void Configure(IApplicationBuilder app)
{
app.UseErrorPage();
app.UseStaticFiles();
app.UseMvcWithDefaultRoute();
app.UseWelcomePage();
}
}
}
Все работает нормально, пока я не включу app.UseStaticFiles(), в который я получаю следующую ошибку:
System.IO.FileLoadException: Could not load file or assembly 'EmailViewer' or one of its dependencies. General Exception (Exception from HRESULT: 0x80131500)
File name: 'EmailViewer' ---> Microsoft.Framework.Runtime.Roslyn.RoslynCompilationException: C:\src\fx5\EmailViewer\Startup.cs(16,13): error CS7069: Reference to type 'IApplicationBuilder' claims it is defined in 'Microsoft.AspNet.Http', but it could not be found
at Microsoft.Framework.Runtime.Roslyn.RoslynProjectReference.Load(IAssemblyLoadContext loadContext)
at Microsoft.Framework.Runtime.Loader.ProjectAssemblyLoader.Load(AssemblyName assemblyName, IAssemblyLoadContext loadContext)
at Microsoft.Framework.Runtime.Loader.ProjectAssemblyLoader.Load(AssemblyName assemblyName)
at dnx.host.LoaderContainer.Load(AssemblyName assemblyName)
at dnx.host.DefaultLoadContext.LoadAssembly(AssemblyName assemblyName)
at Microsoft.Framework.Runtime.Loader.AssemblyLoaderCache.GetOrAdd(AssemblyName name, Func`2 factory)
at Microsoft.Framework.Runtime.Loader.LoadContext.LoadAssemblyImpl(AssemblyName assemblyName)
at Microsoft.Framework.Runtime.Loader.LoadContext.TryLoadAssembly(LoadContext context, AssemblyName assemblyName, Assembly& assembly)
at Microsoft.Framework.Runtime.Loader.LoadContext.ResolveAssembly(Object sender, ResolveEventArgs args)
at System.AppDomain.OnAssemblyResolveEvent(RuntimeAssembly assembly, String assemblyFullName)
at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.Assembly.Load(AssemblyName assemblyRef)
at Microsoft.AspNet.Hosting.Startup.StartupLoader.FindStartupType(String startupAssemblyName, IList`1 diagnosticMessages)
at Microsoft.AspNet.Hosting.Internal.HostingEngine.EnsureStartup()
at Microsoft.AspNet.Hosting.Internal.HostingEngine.EnsureApplicationServices()
at Microsoft.AspNet.Hosting.Internal.HostingEngine.Start()
at Microsoft.AspNet.Hosting.Program.Main(String[] args)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.Framework.Runtime.Common.EntryPointExecutor.Execute(Assembly assembly, String[] args, IServiceProvider serviceProvider)
at Microsoft.Framework.ApplicationHost.Program.ExecuteMain(DefaultHost host, String applicationName, String[] args)
at Microsoft.Framework.ApplicationHost.Program.Main(String[] args)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.Framework.Runtime.Common.EntryPointExecutor.Execute(Assembly assembly, String[] args, IServiceProvider serviceProvider)
at dnx.host.Bootstrapper.RunAsync(List`1 args, IRuntimeEnvironment env)
at dnx.host.RuntimeBootstrapper.ExecuteAsync(String[] args)
at dnx.host.RuntimeBootstrapper.Execute(String[] args)
Microsoft.Framework.Runtime.Roslyn.RoslynCompilationException: C:\src\fx5\EmailViewer\Startup.cs(16,13): error CS7069: Reference to type 'IApplicationBuilder' claims it is defined in 'Microsoft.AspNet.Http', but it could not be found
at Microsoft.Framework.Runtime.Roslyn.RoslynProjectReference.Load(IAssemblyLoadContext loadContext)
at Microsoft.Framework.Runtime.Loader.ProjectAssemblyLoader.Load(AssemblyName assemblyName, IAssemblyLoadContext loadContext)
at Microsoft.Framework.Runtime.Loader.ProjectAssemblyLoader.Load(AssemblyName assemblyName)
at dnx.host.LoaderContainer.Load(AssemblyName assemblyName)
at dnx.host.DefaultLoadContext.LoadAssembly(AssemblyName assemblyName)
at Microsoft.Framework.Runtime.Loader.AssemblyLoaderCache.GetOrAdd(AssemblyName name, Func`2 factory)
at Microsoft.Framework.Runtime.Loader.LoadContext.LoadAssemblyImpl(AssemblyName assemblyName)
at Microsoft.Framework.Runtime.Loader.LoadContext.TryLoadAssembly(LoadContext context, AssemblyName assemblyName, Assembly& assembly)
at Microsoft.Framework.Runtime.Loader.LoadContext.ResolveAssembly(Object sender, ResolveEventArgs args)
at System.AppDomain.OnAssemblyResolveEvent(RuntimeAssembly assembly, String assemblyFullName)
Я пробовал использовать эти версии:
- 1.0.0-beta4
- 1.0.0-beta6-12114
Я не могу понять, что я делаю неправильно. Есть идеи? Спасибо заранее!