首页
学习
活动
专区
圈层
工具
发布
社区首页 >专栏 >【问题解决】Mono下部署ASP.NET应用提示:System.IO.FileNotFoundException

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

作者头像
KenTalk
发布于 2018-09-11 14:33:16
发布于 2018-09-11 14:33:16
1.7K0
举报
文章被收录于专栏:Ken的杂谈Ken的杂谈
一、前言
  • 本篇文章解决办法适用范围?
  1. 错误提示为找不到roslyn编译器 (通常项目为VS2107创建会碰到这个问题)二、解决分析&方案
  • 错误信息
代码语言: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 删除
目录
  • 一、前言
  • 三、解决办法
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档