向script#项目添加web服务引用

本文关键字:服务 引用 web 添加 script# 项目 | 更新日期: 2023-09-27 17:53:35

我正在尝试添加对我在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的控制台项目没有任何问题。

你能添加web引用到一个scripsharp项目吗?有什么具体的程序要遵循吗?

向script#项目添加web服务引用

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

我在那里评论过,但会复制到这里,以防将来遇到同样的问题:

…一些需要记住的上下文内容。

script#不是用来运行。net代码的。它是关于使用c#语言来编写脚本应用程序,并使用脚本环境的功能(在浏览器,在node.js等)。很多问题的答案都是"我该如何……"在脚本#中做x"的问题与"我如何做x ?insert_your_script_environment"。

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