C# 在智能设备应用程序中使用ASP.NETWebAPI

C# 在智能设备应用程序中使用ASP.NETWebAPI,c#,asp.net-web-api,visual-studio-2008,smart-device,notimplementedexception,C#,Asp.net Web Api,Visual Studio 2008,Smart Device,Notimplementedexception,我有一个智能设备应用程序,它将在Zebra MC9200 pocket pc(带有Windows CE 7)中运行 我已经没有任何问题地创建了UI,现在我需要在应用程序上使用我的ASP.NETWebAPI,这样我就可以在数据库上获取和发布数据 我的应用程序是一个智能设备应用程序(适用于Windows CE),是在Windows 7虚拟机上使用Visual Studio 2008和.NET Compact Framework 3.5开发的 我的ASP.Net Web API是在Windows 10

我有一个智能设备应用程序,它将在Zebra MC9200 pocket pc(带有Windows CE 7)中运行

我已经没有任何问题地创建了UI,现在我需要在应用程序上使用我的ASP.NETWebAPI,这样我就可以在数据库上获取和发布数据

我的应用程序是一个智能设备应用程序(适用于Windows CE),是在Windows 7虚拟机上使用Visual Studio 2008和.NET Compact Framework 3.5开发的

我的ASP.Net Web API是在Windows 10主机上使用Visual Studio 2019和.Net Framework 4.7.2开发的,托管在IIS Express上,通过企业内部网分发

我们的数据库是SQL Server 2014(这意味着我不能直接在VS2008应用程序中开发web服务)

在web上搜索我附带了以下代码:

    try
        {
            string url = "*<my api url>*";
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
            request.Method = "GET";
            request.Accept = "application/xml";
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
            response.ContentType = "application/xml";
            Stream stream = response.GetResponseStream();

            using (XmlReader reader = XmlReader.Create(new StreamReader(stream)))
            {
                var doc = XDocument.Load(reader);
                MessageBox.Show(doc.ToString());
            }
        }
        catch (Exception e)
        {
            MessageBox.Show(e.Message);
        }
试试看
{
字符串url=“**”;
HttpWebRequest请求=(HttpWebRequest)WebRequest.Create(url);
request.Method=“GET”;
request.Accept=“application/xml”;
HttpWebResponse=(HttpWebResponse)request.GetResponse();
response.ContentType=“应用程序/xml”;
Stream=response.GetResponseStream();
使用(XmlReader=XmlReader.Create(新建StreamReader(stream)))
{
var doc=XDocument.Load(读卡器);
Show(doc.ToString());
}
}
捕获(例外e)
{
MessageBox.Show(e.Message);
}
但当我调试应用程序时,当调试器尝试执行响应时,我会收到NotImplementedException;此方法的行


有人知道如何修复此异常吗?或者从api中检索数据的另一种方法,可能是使用JSON。

您可以使用RestSharp的第三方api。但是,您需要使用一个非常旧的RestSharp版本,谢谢,我将尝试按照帖子上的说明操作!