【问题标题】:Adding a web service reference to a script# project向脚本# 项目添加 Web 服务引用
【发布时间】:2014-03-25 13:40:20
【问题描述】:

我正在尝试将我在 Microsoft Azure 中托管的 Web 服务的引用添加到 Script# 项目中,但我遇到了一些问题。

目前我正在尝试尽可能干净,所以我在一个 Script#>jQuery 脚本库项目中工作,除了自动生成的代码之外什么都没有。如果我右键单击解决方案 > 添加服务引用 > 高级... > 添加 Web 引用,然后编译我会得到大量的不兼容错误:

Error   1   The type or namespace name 'GeneratedCodeAttributeAttribute' does not exist in the namespace 'System.CodeDom.Compiler' (are you missing an assembly reference?) C:\Users\Axel\Documents\Visual Studio 2012\Projects\ScriptSharpEmAirTest\ScriptSharpEmAirTest\Properties\Settings.Designer.cs   15  38  ScriptSharpEmAirTest
Error   2   The type 'System.CodeDom.Compiler.GeneratedCodeAttribute' exists in both 'c:\Users\Axel\Documents\Visual Studio 2012\Projects\ScriptSharpEmAirTest\packages\ScriptSharp.0.7.5.1\tools\mscorlib.dll' and 'c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.dll' C:\Users\Axel\Documents\Visual Studio 2012\Projects\ScriptSharpEmAirTest\ScriptSharpEmAirTest\Properties\Settings.Designer.cs   15  38  ScriptSharpEmAirTest
Error   3   The type or namespace name 'GeneratedCodeAttributeAttribute' does not exist in the namespace 'System.CodeDom.Compiler' (are you missing an assembly reference?) C:\Users\Axel\Documents\Visual Studio 2012\Projects\ScriptSharpEmAirTest\ScriptSharpEmAirTest\Web References\net.azurewebsites.emair\Reference.cs   26  30  ScriptSharpEmAirTest
Error   4   The type 'System.CodeDom.Compiler.GeneratedCodeAttribute' exists in both 'c:\Users\Axel\Documents\Visual Studio 2012\Projects\ScriptSharpEmAirTest\packages\ScriptSharp.0.7.5.1\tools\mscorlib.dll' and 'c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.dll' C:\Users\Axel\Documents\Visual Studio 2012\Projects\ScriptSharpEmAirTest\ScriptSharpEmAirTest\Web References\net.azurewebsites.emair\Reference.cs   26  30  ScriptSharpEmAirTest
Error   5   The type or namespace name 'DebuggerStepThroughAttributeAttribute' does not exist in the namespace 'System.Diagnostics' (are you missing an assembly reference?)    C:\Users\Axel\Documents\Visual Studio 2012\Projects\ScriptSharpEmAirTest\ScriptSharpEmAirTest\Web References\net.azurewebsites.emair\Reference.cs   27  25  ScriptSharpEmAirTest
Error   6   The type or namespace name 'DebuggerStepThroughAttribute' does not exist in the namespace 'System.Diagnostics' (are you missing an assembly reference?) C:\Users\Axel\Documents\Visual Studio 2012\Projects\ScriptSharpEmAirTest\ScriptSharpEmAirTest\Web References\net.azurewebsites.emair\Reference.cs   27  25  ScriptSharpEmAirTest
Error   7   The type or namespace name 'DebuggerNonUserCodeAttributeAttribute' does not exist in the namespace 'System.Diagnostics' (are you missing an assembly reference?)    C:\Users\Axel\Documents\Visual Studio 2012\Projects\ScriptSharpEmAirTest\ScriptSharpEmAirTest\Properties\Settings.Designer.cs   27  37  ScriptSharpEmAirTest
Error   8   The type or namespace name 'DebuggerNonUserCodeAttribute' does not exist in the namespace 'System.Diagnostics' (are you missing an assembly reference?) C:\Users\Axel\Documents\Visual Studio 2012\Projects\ScriptSharpEmAirTest\ScriptSharpEmAirTest\Properties\Settings.Designer.cs   27  37  ScriptSharpEmAirTest
Error   9   The type or namespace name 'SendOrPostCallback' does not exist in the namespace 'System.Threading' (are you missing an assembly reference?) C:\Users\Axel\Documents\Visual Studio 2012\Projects\ScriptSharpEmAirTest\ScriptSharpEmAirTest\Web References\net.azurewebsites.emair\Reference.cs   33  34  ScriptSharpEmAirTest
Error   10  The type or namespace name 'SendOrPostCallback' does not exist in the namespace 'System.Threading' (are you missing an assembly reference?) C:\Users\Axel\Documents\Visual Studio 2012\Projects\ScriptSharpEmAirTest\ScriptSharpEmAirTest\Web References\net.azurewebsites.emair\Reference.cs   35  34  ScriptSharpEmAirTest
Error   11  The type or namespace name 'SendOrPostCallback' does not exist in the namespace 'System.Threading' (are you missing an assembly reference?) C:\Users\Axel\Documents\Visual Studio 2012\Projects\ScriptSharpEmAirTest\ScriptSharpEmAirTest\Web References\net.azurewebsites.emair\Reference.cs   37  34  ScriptSharpEmAirTest
Error   12  The type or namespace name 'SendOrPostCallback' does not exist in the namespace 'System.Threading' (are you missing an assembly reference?) C:\Users\Axel\Documents\Visual Studio 2012\Projects\ScriptSharpEmAirTest\ScriptSharpEmAirTest\Web References\net.azurewebsites.emair\Reference.cs   39  34  ScriptSharpEmAirTest

(实际上有158个这样的错误)

显然,在添加 webreference 之前进行编译可以顺利进行,具有相同 webreference 的控制台项目不会出现任何问题。

您可以将 webreferences 添加到 scripsharp 项目吗?有具体的流程吗?

【问题讨论】:

  • 这是不可能的,script# 仅支持 .net Framework 的最小子集。
  • 是否有官方声明表明这是不可能的?也许是 NikhilK 的评论?

标签: c# web-services script#


【解决方案1】:

https://github.com/nikhilk/scriptsharp/issues/414#issuecomment-39080016 相同的问题?

我在那里发表了评论,但会在这里复制,以供将来偶然发现相同问题/问题的人使用:

...要记住一些上下文相关的东西。

Script# 不是关于运行 .net 代码的。它关于使用 c# 语言 编写脚本应用程序,并使用脚本环境的功能 (在浏览器中,在 node.js 等中)。许多这些问题的答案“我如何 do x in script#”问题与“how do I do x in insert_your_script_environment”。

所以,如前所述,在 JavaScript 客户端中,您可能(或者我 理想情况下应该说,因为基于 WCF 的情况并非如此 有时实现)与具有简单 REST API 的服务一起工作 说JSON。这同样适用于脚本#。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-06-25
    • 1970-01-01
    • 1970-01-01
    • 2013-02-02
    • 1970-01-01
    • 2011-01-23
    • 2011-10-13
    相关资源
    最近更新 更多