【问题标题】:Compile C# class using SOAP Web Reference into .dll Error CS0234使用 SOAP Web 引用将 C# 类编译为 .dll 错误 CS0234
【发布时间】:2014-09-05 18:35:02
【问题描述】:

您好,我正在尝试将 compile 我的 C# 代码转换为 .dll 文件,以便在 VBA script 中使用客户端。

我的 C# 代码引用了一个 SOAP Web 服务并且表现不佳。当我运行csc /target:library file.cs 时,com 上出现以下错误 CS0234 和 CS0246 BbsSecurityContext,BbsEntityResult(Web 服务中的类)。它说com 命名空间在命名空间SOAPTest 中不存在。如果我能提供更多信息,请告诉我。

这是文件中的一个sn-p代码

...
using SOAPTest.com.blueberryhosting.broadviewbbsvcstg;
using System.Runtime.InteropServices;

namespace SOAPTest
{
    [Guid("9E5E5FB2-219D-4ee7-AB27-E4DBED8E123E")]
    [ClassInterface(ClassInterfaceType.AutoDual)]
    public class Webservice
    {
        private BbsSecurityContext sc;

        public Webservice(string apiKey, string sourceSystem, int userID)
        {
            createSecurityContext(apiKey, sourceSystem, userID);
        }
...
public void getInvestors(string filepath)
{
    using (BbsInteropWebService ws = new BbsInteropWebService())
     {
           BbsEntityResult x = ws.GetInvestors(sc);
           if(x.Success)
           {
           generateCSV(x,filepath);
           }
     }
}
...

【问题讨论】:

    标签: c# .net web-services vba soap


    【解决方案1】:

    您的 sn-p 包括 using SOAPTest.com.blueberryhosting.broadviewbbsvcstg;。我怀疑您收到了错误,因为您指定的 csc.exe 命令仅包含 file.cs 并且该名称空间未在文件中定义。很可能它是在另一个代码文件或库中定义的。调用编译器时需要提供所有依赖项。

    Command-line Building With csc.exe

    How to use references when compiling c# code via command line

    【讨论】:

    • 哇,谢谢你回答这个问题赛斯!我会在我周三回去工作时调查一下。
    猜你喜欢
    • 2013-01-08
    • 1970-01-01
    • 1970-01-01
    • 2021-03-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多