2016-01-12 17 views
7

Tôi có một ứng dụng web Asp.net 5 hoạt động và chạy tốt trong phát triển (từ Visual Studio hoặc mã VS tôi có thể khởi chạy không có vấn đề). Tuy nhiên, sau khi xuất bản thành công các ứng dụng, khi cố gắng để khởi động trang web với "web.cmd" các lỗi sau xuất hiện và ngăn chặn các trang web từ bao giờ tải:Asp.net 5 Ngoại lệ khởi động ứng dụng Web sau khi xuất bản thành công

Application startup exception: System.IO.FileNotFoundException: Could not load file or assembly 'my-ng2-website' or one of its dependencies. The system cannot find the file specified. 
 
File name: 'my-ng2-website' ---> System.IO.FileNotFoundException: The system cannot find the file specified. (Exception from HRESULT: 0x80070002) 
 
    at System.Reflection.RuntimeAssembly.nLoadFile(String path, Evidence evidence) 
 
    at System.Reflection.Assembly.LoadFile(String path) 
 
    at Microsoft.Dnx.Runtime.Loader.LoadContext.LoadFile(String assemblyPath) 
 
    at Microsoft.Dnx.Runtime.Loader.PackageAssemblyLoader.Load(AssemblyName assemblyName, IAssemblyLoadContext loadContext) 
 
    at Microsoft.Dnx.Runtime.Loader.PackageAssemblyLoader.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.LoadAssemblyImpl(AssemblyName assemblyName) 
 
    at Microsoft.Dnx.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.BuildApplication()

Tôi đã tìm kiếm cao và thấp cho các giải pháp. Tôi không thể tìm ra sự phụ thuộc mà tôi đang thiếu. Tôi đã thử

xóa package.lock.json

DNU khôi phục

Dưới đây là DNX thiết lập cấu hình của tôi cho dự án: enter image description here

Dưới đây là các thiết lập cho xuất bản:

enter image description here

Ai có thể đọc những lá trà này không?

+0

công bố thay đổi cài đặt ** my-ng2-website ** để ** my-ng2-website-biên soạn ** – ymz

+0

có đó là lỗi đánh máy - nhưng các cài đặt xuất bản thực sự là một thứ hoàn toàn khác. tôi đã tạo "my-ng2-website" để hiển thị ở đây – brando

+0

Việc lắp ráp có được xuất bản không? Hoặc có thể nó được đổi tên khi xuất bản. – jtlowe

Trả lời

1

Chỉ vì vấn đề này, tôi đặt "biên dịch tệp nguồn thành Gói Nuget" thành sai. Và bây giờ nó hoạt động.

enter image description here

Tại sao nó hoạt động, tôi không biết. Nhưng hy vọng điều này sẽ giúp người khác.

1

Ngày tốt lành. Chúng tôi đã gặp vài lần gặp lỗi này. Nó thường lần điểm đến một hội đồng thiếu (một trong những phổ biến nhất). Kiểm tra tất cả các tham chiếu cần thiết, thiết lập để Copy Local -> true, giúp hầu hết thời gian. Vì các assembly/tham chiếu sẽ không được đưa vào trong publish nếu nó được đặt thành Copy Local -> false.

Hy vọng điều này sẽ hữu ích.

+0

Nơi nào bạn đặt Sao chép Địa phương -> true? Trong hồ sơ công khai có một thiết lập CopyLocalFilesOutputGroupDependsOn. – brando

+0

tôi có nghĩa là xuất bản hồ sơ, chứ không phải hồ sơ công khai – brando

0

Lỗi này có liên quan đến tệp global.json nằm trong thư mục dự án (không phải là giải pháp). Nếu bạn muốn xuất bản dự án với các tùy chọn biên dịch trên chắc chắn để thêm nó vào publishExclude trong bạn project.json

"publishExclude": [ 
    "**.user", 
    "**.vspscc", 
    "global.json" 
], 
Các vấn đề liên quan