RazorEngine on Mono - TemplateCompilationException thrown

狂风中的少年 提交于 2019-12-13 03:00:25

问题


I have Mono 3.3.0 running on my Linux box. I am trying to use RazorEngine 3.3.0 (from NuGet).

Unfortunately it now throws this exception

System.Exception: Unable to compile template. The predefined type System.Collections.Generic.IReadOnlyList' is defined multiple times. Using definition frommscorlib.dll'

However the code works just fine on my Windows machine. Am I missing something obvious, or does this simply not work on Mono?

[Edit]

I just found this information in the "Errors" property of the exception.

{'Line': '0', 'Column': '0', 'ErrorNumber': 'CS1685', 'IsWarning': 'True', 'ErrorText': 'The predefined type System.Collections.Generic.IReadOnlyList' is defined multiple times. Using definition frommscorlib.dll'', 'Filename': ''} {'Line': '0', 'Column': '0', 'ErrorNumber': '', 'IsWarning': 'False', 'ErrorText': '/usr/lib/mono/4.5/mscorlib.dll (Location of the symbol related to previous warning)', 'Filename': ''} {'Line': '0', 'Column': '0', 'ErrorNumber': '', 'IsWarning': 'False', 'ErrorText': '/usr/lib/mono/gac/fastcgi-mono-server4/3.0.0.0_0738eb9f132ed756/fastcgi-mono-server4.exe (Location of the symbol related to previous warning)', 'Filename': ''} {'Line': '0', 'Column': '0', 'ErrorNumber': 'CS1685', 'IsWarning': 'True', 'ErrorText': 'The predefined type System.Collections.Generic.IReadOnlyCollection' is defined multiple times. Using definition frommscorlib.dll'', 'Filename': ''} {'Line': '0', 'Column': '0', 'ErrorNumber': '', 'IsWarning': 'False', 'ErrorText': '/usr/lib/mono/4.5/mscorlib.dll (Location of the symbol related to previous warning)', 'Filename': ''} {'Line': '0', 'Column': '0', 'ErrorNumber': '', 'IsWarning': 'False', 'ErrorText': '/usr/lib/mono/gac/fastcgi-mono-server4/3.0.0.0_0738eb9f132ed756/fastcgi-mono-server4.exe (Location of the symbol related to previous warning)', 'Filename': ''}


回答1:


I found this https://askubuntu.com/questions/315713/trouble-compiling-monodevelop-4-on-ubuntu-12-04

And it had me thinking of how I installed Mono. I installed from a gz file, and then from Git (to get the latest version), which ultimately gave me two copies. Unfortunately I cannot install directly from Git (as it requires Mono installed to be able to build...). So I just reversed to the gz, and the issue was automatically resolved!

So basically, two instances of Mono existed at the same time (somehow), and RazorEngine was the first thing to point this out to me (yet everything else worked just fine).




回答2:


If you just have one Mono install, take a look at the solution I described here: Razor Engine on Mono 3.2.x with Fast CGI - target specific .net?



来源:https://stackoverflow.com/questions/18551661/razorengine-on-mono-templatecompilationexception-thrown

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!