如何为Asp运行Xamarin.Net在Mac上不使用sudo

本文关键字:Mac sudo Net Asp 运行 Xamarin | 更新日期: 2023-09-27 18:14:43

基本上我安装了Mono框架,然后Xamarin Studio。

创建一个Asp。网络应用程序。运行它。得到这个错误:

Application Exception
System.SystemException
Error running mcs: Cannot find the specified file
Description: HTTP 500.Error processing request.
Details: Non-web exception. Exception origin (name of application or object): System.
Exception stack trace:
  at Mono.CSharp.CSharpCodeCompiler.CompileFromFileBatch (System.CodeDom.Compiler.CompilerParameters options, System.String[] fileNames) [0x00135] in /private/tmp/source-mono-mac-4.0.0-branch-c5sr4/bockbuild-mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/mono-4.0.4/mcs/class/System/Microsoft.CSharp/CSharpCodeCompiler.cs:216 
  at Mono.CSharp.CSharpCodeCompiler.CompileAssemblyFromFileBatch (System.CodeDom.Compiler.CompilerParameters options, System.String[] fileNames) [0x00011] in /private/tmp/source-mono-mac-4.0.0-branch-c5sr4/bockbuild-mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/mono-4.0.4/mcs/class/System/Microsoft.CSharp/CSharpCodeCompiler.cs:136 
  at System.CodeDom.Compiler.CodeDomProvider.CompileAssemblyFromFile (System.CodeDom.Compiler.CompilerParameters options, System.String[] fileNames) [0x00014] in /private/tmp/source-mono-mac-4.0.0-branch-c5sr4/bockbuild-mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/mono-4.0.4/mcs/class/System/System.CodeDom.Compiler/CodeDomProvider.cs:111 
  at System.Web.Compilation.AssemblyBuilder.BuildAssembly (System.Web.VirtualPath virtualPath, System.CodeDom.Compiler.CompilerParameters options) [0x002e8] in /private/tmp/source-mono-mac-4.0.0-branch-c5sr4/bockbuild-mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/mono-4.0.4/mcs/class/System.Web/System.Web.Compilation/AssemblyBuilder.cs:822 
  at System.Web.Compilation.AssemblyBuilder.BuildAssembly (System.Web.VirtualPath virtualPath) [0x00000] in /private/tmp/source-mono-mac-4.0.0-branch-c5sr4/bockbuild-mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/mono-4.0.4/mcs/class/System.Web/System.Web.Compilation/AssemblyBuilder.cs:731 
  at System.Web.Compilation.BuildManager.GenerateAssembly (System.Web.Compilation.AssemblyBuilder abuilder, System.Web.Compilation.BuildProviderGroup group, System.Web.VirtualPath vp, Boolean debug) [0x00264] in /private/tmp/source-mono-mac-4.0.0-branch-c5sr4/bockbuild-mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/mono-4.0.4/mcs/class/System.Web/System.Web.Compilation/BuildManager.cs:826 
  at System.Web.Compilation.BuildManager.BuildInner (System.Web.VirtualPath vp, Boolean debug) [0x0011c] in /private/tmp/source-mono-mac-4.0.0-branch-c5sr4/bockbuild-mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/mono-4.0.4/mcs/class/System.Web/System.Web.Compilation/BuildManager.cs:451 
  at System.Web.Compilation.BuildManager.Build (System.Web.VirtualPath vp) [0x00056] in /private/tmp/source-mono-mac-4.0.0-branch-c5sr4/bockbuild-mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/mono-4.0.4/mcs/class/System.Web/System.Web.Compilation/BuildManager.cs:396 
  at System.Web.Compilation.BuildManager.GetCompiledType (System.Web.VirtualPath virtualPath) [0x00040] in /private/tmp/source-mono-mac-4.0.0-branch-c5sr4/bockbuild-mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/mono-4.0.4/mcs/class/System.Web/System.Web.Compilation/BuildManager.cs:989 
  at System.Web.Compilation.BuildManager.GetCompiledType (System.String virtualPath) [0x00000] in /private/tmp/source-mono-mac-4.0.0-branch-c5sr4/bockbuild-mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/mono-4.0.4/mcs/class/System.Web/System.Web.Compilation/BuildManager.cs:972 
  at System.Web.HttpApplicationFactory.InitType (System.Web.HttpContext context) [0x0016b] in /private/tmp/source-mono-mac-4.0.0-branch-c5sr4/bockbuild-mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/mono-4.0.4/mcs/class/System.Web/System.Web/HttpApplicationFactory.cs:417 
Version Information: 4.0.4 ((detached/cb6d6b2 Thu Sep 10 07:14:07 EDT 2015); ASP.NET Version: 4.0.30319.17020
Powered by Mono  

感觉就像允许,因为它可以构建并且我可以很好地运行控制台应用程序。

所以我试着从终端使用sudo运行Xamarin Studio App。那么问题就解决了。

然而,我不敢相信这是正确的解决方案。想知道是否有人知道如何正确运行这个?

谢谢!

如何为Asp运行Xamarin.Net在Mac上不使用sudo

使用终端查找"mcs"的位置

which mcs

应该是/usr/local/bin/mcs,它不在Xamarin的路径中。通过将mcs链接到/usr/bin

来修复这个问题
sudo ln -s /usr/local/bin/mcs /usr/bin

我也有同样的问题,我安装了Xamarin studio的最新更新,问题解决了。

要做到这一点,请转到Xamarin Studio菜单-> Check for Updates…。您将看到可用更新的列表。下载并安装

希望这对你有帮助!