Linq to XML 需要 VB.NET XML 文字表达式

发布于 2024-09-05 11:50:09 字数 868 浏览 5 评论 0原文

我遇到了与这个问题中所述相同的问题,但已接受解决方案有一个“在我的机器上工作”的答案。

这是我的代码:

Dim document As XDocument = _
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
        <soap12:Body>
            <GetUser xmlns="http://foo.com/bar.asmx">
                <encryptedHash>HashString</encryptedHash>
                <accessKey>AccessString</accessKey>
                <siteUID>SiteString</siteUID>
            </GetUser>
        </soap12:Body>
    </soap12:Envelope>

我收到错误:BC30201:需要表达式。

有谁对可能导致这种情况的原因有更详细的了解?

I have the same problem as stated in this question, but the accepted solution there was a "works on my machine" answer.

Here is my code:

Dim document As XDocument = _
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
        <soap12:Body>
            <GetUser xmlns="http://foo.com/bar.asmx">
                <encryptedHash>HashString</encryptedHash>
                <accessKey>AccessString</accessKey>
                <siteUID>SiteString</siteUID>
            </GetUser>
        </soap12:Body>
    </soap12:Envelope>

And I receive the error: BC30201: Expression expected.

Does anyone have a more detailed idea of what could cause this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

幻梦 2024-09-12 11:50:09

好的,Rubber Duck 调试——

即使项目设置为面向 .NET 3.5,对于无论 web.config 丢失的原因是什么:

 <system.codedom>
<compilers>
  <compiler language="c#;cs;csharp" extension=".cs"
            type="Microsoft.CSharp.CSharpCodeProvider,System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
            warningLevel="4">
    <providerOption name="CompilerVersion" value="v3.5"/>
    <providerOption name="WarnAsError" value="false"/>
  </compiler>
  <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb"
            type="Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
            warningLevel="4">
    <providerOption name="CompilerVersion" value="v3.5"/>
    <providerOption name="OptionInfer" value="true"/>
    <providerOption name="WarnAsError" value="false"/>
  </compiler>
</compilers>

所以我猜它没有在 3.5 中运行。一旦我将上述内容添加到 web.config 中,它就会编译。

Ok, Rubber Duck debugging --

Even though the project was set to target .NET 3.5, for whatever reason the web.config was missing:

 <system.codedom>
<compilers>
  <compiler language="c#;cs;csharp" extension=".cs"
            type="Microsoft.CSharp.CSharpCodeProvider,System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
            warningLevel="4">
    <providerOption name="CompilerVersion" value="v3.5"/>
    <providerOption name="WarnAsError" value="false"/>
  </compiler>
  <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb"
            type="Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
            warningLevel="4">
    <providerOption name="CompilerVersion" value="v3.5"/>
    <providerOption name="OptionInfer" value="true"/>
    <providerOption name="WarnAsError" value="false"/>
  </compiler>
</compilers>

So I guess it wasn't running in 3.5. As soon as I added the above to the web.config it compiled.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文