我们正在使用Razor语法开发一个Html模板引擎,该引擎将Html模板转换为scrip#代码。
当我们在ScriptSharp项目中添加cshtml文件时,RazorEditor在visual studio中提供的intellisense将System、System.Collections命名空间和这些命名空间中的类型解析为.net Framework mscorlib.dll,而不是ScriptSharp mscorlibdll。但是C#代码编辑器中的intellisense正确地将命名空间解析为Script#mscorlib,因为Script#项目的csproj文件包含包含脚本#mscorlib.dll的文件夹的ReferencePath。
我试过以下,但没有运气
-
在ScriptSharp项目文件夹中添加了web.config文件,并
显式添加了对ScriptSharp mscorlib dll的引用
insystem.web>编译>程序集部分。 -
创建了一个bin文件夹并复制了scriptsharp mscorlib dll。
有没有办法提示Razor编辑器选择脚本#mscorlib.dll,而不是.net Framework mscorlib.dll?
Razor使用了一个特殊的配置部分,类似于这样,它不使用compilation
元素。
<system.web.webPages.razor>
...
<pages pageBaseType="System.Web.Mvc.WebViewPage">
<assemblies>
...
</assemblies>
<namespaces>
...
</namespaces>
</pages>
</system.web.webPages.razor>
您还需要添加此配置部分的定义:
<configSections>
<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
</sectionGroup>
</configSections>