前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >【问题解决】Mono下部署ASP.NET应用提示:System.IO.FileNotFoundException

【问题解决】Mono下部署ASP.NET应用提示:System.IO.FileNotFoundException

作者头像
KenTalk
发布2018-09-11 14:33:16
1.2K0
发布2018-09-11 14:33:16
举报
文章被收录于专栏:Ken的杂谈Ken的杂谈
一、前言
  • 本篇文章解决办法适用范围?
  1. 错误提示为找不到roslyn编译器 (通常项目为VS2107创建会碰到这个问题)二、解决分析&方案
  • 错误信息
image
image
代码语言:javascript
复制
System.IO.FileNotFoundException
Could not find file "/mysiteroot/bin\roslyn\csc.exe".

Description: HTTP 500.Error processing request.
Details: Non-web exception. Exception origin (name of application or object): mscorlib.
Exception stack trace:
  at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.Boolean anonymous, System.IO.FileOptions options) [0x0019c] in <3753d1715b8842d8bb13a30db0388b60>:0 
  at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share) [0x00000] in <3753d1715b8842d8bb13a30db0388b60>:0 
  at (wrapper remoting-invoke-with-check) System.IO.FileStream:.ctor (string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare)
  at System.IO.File.OpenRead (System.String path) [0x00000] in <3753d1715b8842d8bb13a30db0388b60>:0 
  at Microsoft.CodeDom.Providers.DotNetCompilerPlatform.Compiler.get_CompilerName () [0x00019] in <13231d2f854e4437bf639e10b63dd37e>:0 
  at Microsoft.CodeDom.Providers.DotNetCompilerPlatform.Compiler.FromFileBatch (System.CodeDom.Compiler.CompilerParameters options, System.String[] fileNames) [0x00168] in <13231d2f854e4437bf639e10b63dd37e>:0 
  at Microsoft.CodeDom.Providers.DotNetCompilerPlatform.Compiler.CompileAssemblyFromFileBatch (System.CodeDom.Compiler.CompilerParameters options, System.String[] fileNames) [0x00048] in <13231d2f854e4437bf639e10b63dd37e>:0 
  at System.CodeDom.Compiler.CodeDomProvider.CompileAssemblyFromFile (System.CodeDom.Compiler.CompilerParameters options, System.String[] fileNames) [0x00006] in <1d7393d853954016b607e8e348b00ad1>:0 
  at System.Web.Compilation.AssemblyBuilder.BuildAssembly (System.Web.VirtualPath virtualPath, System.CodeDom.Compiler.CompilerParameters options) [0x0029f] in <8fe6d5c66f4c4efb8f2d2af3ae3c8850>:0 
  at System.Web.Compilation.AssemblyBuilder.BuildAssembly (System.Web.VirtualPath virtualPath) [0x00008] in <8fe6d5c66f4c4efb8f2d2af3ae3c8850>:0 
  at System.Web.Compilation.BuildManager.GenerateAssembly (System.Web.Compilation.AssemblyBuilder abuilder, System.Web.Compilation.BuildProviderGroup group, System.Web.VirtualPath vp, System.Boolean debug) [0x00202] in <8fe6d5c66f4c4efb8f2d2af3ae3c8850>:0 
  at System.Web.Compilation.BuildManager.BuildInner (System.Web.VirtualPath vp, System.Boolean debug) [0x00106] in <8fe6d5c66f4c4efb8f2d2af3ae3c8850>:0 
  at System.Web.Compilation.BuildManager.Build (System.Web.VirtualPath vp) [0x00058] in <8fe6d5c66f4c4efb8f2d2af3ae3c8850>:0 
  at System.Web.Compilation.BuildManager.GetCompiledType (System.Web.VirtualPath virtualPath) [0x00037] in <8fe6d5c66f4c4efb8f2d2af3ae3c8850>:0 
  at System.Web.Compilation.BuildManager.GetCompiledType (System.String virtualPath) [0x00006] in <8fe6d5c66f4c4efb8f2d2af3ae3c8850>:0 
  at System.Web.HttpApplicationFactory.InitType (System.Web.HttpContext context) [0x00219] in <8fe6d5c66f4c4efb8f2d2af3ae3c8850>:0 
  at System.Web.HttpApplicationFactory.GetApplication (System.Web.HttpContext context) [0x00018] in <8fe6d5c66f4c4efb8f2d2af3ae3c8850>:0 
  at System.Web.HttpRuntime.Process (System.Web.HttpWorkerRequest req) [0x00052] in <8fe6d5c66f4c4efb8f2d2af3ae3c8850>:0

实际错误诱因:

代码语言:javascript
复制
Could not find file "/mysiteroot/bin\roslyn\csc.exe".

也就是站点启动时找不到站点根目录bin文件夹中的roslyn编译器 由于Mono不兼容roslyn那我们只能考虑改用msbuild 一个项目的编译信息是由.csproj文件存储的,那具体怎么解决这个问题 就只能从这个文件入手

分析.csproj文件发现跟roslyn相关的配置

代码语言:javascript
复制
 <Import Project="..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.3\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props" Condition="Exists('..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.3\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" />
<Import Project="..\packages\Microsoft.Net.Compilers.1.3.2\build\Microsoft.Net.Compilers.props" Condition="Exists('..\packages\Microsoft.Net.Compilers.1.3.2\build\Microsoft.Net.Compilers.props')" />

也就是说项目中安装了如下两个package:

代码语言:javascript
复制
Microsoft.CodeDom.Providers.DotNetCompilerPlatform
Microsoft.Net.Compilers
三、解决办法
代码语言:javascript
复制
#通过nuget卸载这两个package即可
uninstall-package Microsoft.CodeDom.Providers.DotNetCompilerPlatform
uninstall-package Microsoft.Net.Compilers
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2017-07-04 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 一、前言
  • 三、解决办法
相关产品与服务
文件存储
文件存储(Cloud File Storage,CFS)为您提供安全可靠、可扩展的共享文件存储服务。文件存储可与腾讯云服务器、容器服务、批量计算等服务搭配使用,为多个计算节点提供容量和性能可弹性扩展的高性能共享存储。腾讯云文件存储的管理界面简单、易使用,可实现对现有应用的无缝集成;按实际用量付费,为您节约成本,简化 IT 运维工作。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档