2010-06-09 68 views
0

我有與this question中所述相同的問題,但接受的解決方案有一個「在我的機器上工作」的答案。VB.NET XML文字表達預期與Linq到XML

這裏是我的代碼:

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:表達期望。

有沒有人有更詳細的想法可能會導致此?

+0

您使用的是什麼版本的Visual Studio?這對我的2010年安裝很好。 – JaredPar 2010-06-09 15:12:28

+0

VS2008和該項目的目標.NET 3.5 – plntxt 2010-06-09 15:19:49

回答

1

好吧,Rubber Duck debugging -

即使該項目被設置爲面向.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中就可以編譯。