[英]C# String-Interpolation in InfoPath Form
I am trying to add some code to an InfoPath 2013
form for use on a SharePoint 2013
website.我正在尝试向
InfoPath 2013
表单添加一些代码,以便在SharePoint 2013
网站上使用。
This appears to be working normally after installing Visual Studio 2012
and opening it via InfoPath
.这似乎在安装
Visual Studio 2012
并通过InfoPath
打开后正常工作。
However, after importing some of my old code (which makes use of the string-interpolation introduced in C# 6.0
), I now see this error:但是,在导入我的一些旧代码(使用
C# 6.0
引入的字符串插值)后,我现在看到了这个错误:
Unexpected character '$'
意外字符“$”
On lines where interpolation is used.在使用插值的行上。
I tried running Install-Package Microsoft.Net.Compilers -Version 1.3.2
, but NuGet
complains that:我尝试运行
Install-Package Microsoft.Net.Compilers -Version 1.3.2
,但NuGet
抱怨:
The element 'metadata' in namespace ' http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd ' has invalid child element 'developmentDependency' in namespace ' http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd '.
元素命名空间“元数据' http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd具有无效子元素“developmentDependency”命名空间” http://schemas.microsoft.com/packaging/ 2010/07/nuspec.xsd '。
List of possible elements expected: 'iconUrl, summary, title, projectUrl, references, frameworkAssemblies, copyright, releaseNotes, licenseUrl, tags, dependencies, language, description' in namespace ' http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd '.
预期的可能元素列表:命名空间“ http://schemas.microsoft.com/packaging/2010/ ”中的“iconUrl、摘要、标题、projectUrl、引用、frameworkAssemblies、版权、releaseNotes、licenseUrl、标签、依赖项、语言、描述” 07/nuspec.xsd '。
So I tried update NuGet
as per this answer , but then I see:所以我尝试按照这个答案更新
NuGet
,但后来我看到:
The term 'nuget' is not recognized as the name of a cmdlet, function, script file, or operable program.
术语“nuget”不被识别为 cmdlet、函数、脚本文件或可运行程序的名称。 Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
检查名称的拼写,或者如果包含路径,请验证路径是否正确,然后重试。
What is going on here?这里发生了什么? Am I wasting my time trying to use
C# 6.0
with InfoPath
, or is there something wrong with my configuration?我是在浪费时间尝试将
C# 6.0
与InfoPath
,还是我的配置有问题?
Please note that InfoPath 2013
will only allow custom code if using Visual Studio 2012
.请注意,
InfoPath 2013
只允许使用Visual Studio 2012
自定义代码。 Other wise I would be using 2015
.否则我会使用
2015
。
I was able to resolve this by following these steps:我能够通过以下步骤解决这个问题:
First, update NuGet
using the following method:首先,使用以下方法更新
NuGet
:
Next, exit Visual Studio 2012
and InfoPath 2013
(note that exiting only VS
will not work, as InfoPath
appears to keep it open in the background for quick access).接下来,退出
Visual Studio 2012
和InfoPath 2013
(请注意,仅退出VS
将不起作用,因为InfoPath
似乎在后台保持打开状态以便快速访问)。
Now, Start both up again and try again.现在,再次启动并重试。 This time, I was able to run
Install-Package Microsoft.Net.Compilers
in the Package Manager Console
and C# 6.0
appears to have been installed.这一次,我能够在
Package Manager Console
运行Install-Package Microsoft.Net.Compilers
并且似乎已经安装了C# 6.0
。
VS2012
sill processes the new string-interpolation as an error, so these do appear in the error window and I can see squiggly red underlining in the text editor. VS2012
sill 将新的字符串插值作为错误处理,所以这些确实出现在错误窗口中,我可以在文本编辑器中看到波浪形的红色下划线。
I have opted to forgo the new string-interpolation as dealing with these fake errors is too annoying.我选择放弃新的字符串插值,因为处理这些假错误太烦人了。 I did this by unloading my
.csproj
file and removing the reference to Microsoft.Net.Compilers
.我通过卸载我的
.csproj
文件并删除对Microsoft.Net.Compilers
的引用来做到这一点。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.