简体   繁体   English

将Web服务引用添加到script#项目

[英]Adding a web service reference to a script# project

I'm trying to add a reference to a webservice that I have hosted in Microsoft Azure to a Script# project and I'm having a couple of issues with it. 我试图将对我在Microsoft Azure中托管的Web服务的引用添加到Script#项目中,但遇到了一些问题。

At the moment I'm trying to do it as clean as possible so I'm working in a Script#>jQuery Script library project with nothing but the auto-generated code. 目前,我正在尝试使其尽可能干净,因此我正在Script#> jQuery Script库项目中工作,仅使用自动生成的代码。 If I right-click the solution > Add service reference > Advanced... > Add web reference and then compile I get an important amount of incompatibility errors: 如果右键单击解决方案>添加服务引用>高级...>添加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

(There are actually 158 errors like that) (实际上有158个错误)

Evidently, compiling before adding the webreference goes smoothly and a console porject with the same webreference sees no issues. 显然,在添加Web引用之前进行的编译很顺利,并且具有相同Web引用的控制台项目不会出现任何问题。

Can you add webreferences to a scripsharp project? 您可以向scripsharp项目添加Web引用吗? is there a specific procedure to follow? 有没有遵循的特定程序?

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

I commented there, but will copy here, for those who stumble on the same issue/question in the future: 我在此处评论过,但会在此处复制,以供将来偶然发现相同问题的人使用:

... some contextual stuff to keep in mind. ...一些需要注意的内容。

Script# is not about running .net code. 脚本号与运行.net代码无关。 Its about using c# language to author script apps, and use the capabilities of scripting environments (in browser, in node.js etc.). 它涉及使用c#语言编写脚本应用程序,以及使用脚本环境的功能(在浏览器中,在node.js等中)。 The answer to many of these "how do I do x in script#" questions is the same as "how do I do x in insert_your_script_environment". 这些“如何在脚本#中执行x”问题中的许多问题的答案与“如何在insert_your_script_environment中执行x”相同。

So, as mentioned, in a JavaScript client, you'd likely (or maybe I should say ideally, since this isn't the case with WCF-based implementations sometimes) work with a service with a simple REST API that speaks JSON. 因此,如上所述,在JavaScript客户端中,您可能会(或者也许我应该说是理想的,因为有时基于WCF的实现不是这种情况)与带有简单JSON的REST API的服务一起使用。 The same applies in script#. 脚本#中也是如此。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM