小编Amz*_*ath的帖子

未为此项目设置OutputPath属性

当我尝试在Visual Studio 2008中从x86调试模式编译我的项目时.我收到此错误.当我查看抱怨的项目的属性组时,我看到输出路径已设置.

这是.csproj文件的属性组部分

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
  <DebugSymbols>true</DebugSymbols>
  <OutputPath>bin\x86\Debug\</OutputPath>
  <DefineConstants>DEBUG;TRACE</DefineConstants>
  <BaseAddress>285212672</BaseAddress>
  <FileAlignment>4096</FileAlignment>
  <DebugType>full</DebugType>
  <PlatformTarget>x86</PlatformTarget>
 <ErrorReport>prompt</ErrorReport>
Run Code Online (Sandbox Code Playgroud)

任何人都可以阐明这一点吗?

注意:当我编译这个Debug和任何CPU时,它工作.

更新:错误1未为此项目设置OutputPath属性.请检查以确保您已指定有效的配置/平台组合.Configuration ='Debug'Blatter ='x86'

c# visual-studio

110
推荐指数
8
解决办法
11万
查看次数

WCF中OperationTimeout和SendTimeout之间的区别

经过相当多的搜索,我找不到这个问题的答案.

OperationTimeout和之间的确切区别是什么SendTimeout?我读OperationTimeout的一个子集SendTimeout,并SendTimeout包括在所述信道写消息.如果您提供更多详细信息,那就太棒了.

我的第二个问题是我有一个客户端调用服务,我只想在发送到服务器的请求之后不久和服务器收到回复之后设置超时.如何设置此超时?

c# wcf

16
推荐指数
1
解决办法
2万
查看次数

通过https调用获取EOF异常

我的代码发出https请求.这是我的代码

HttpWebRequest request = (HttpWebRequest)WebRequest.Create(UploadUrl);
            request.Method = "POST";
            request.KeepAlive = false;
            request.Credentials = new NetworkCredential(userid, testpwd);

            postData = "<root></root>";
            request.ContentType = "application/x-www-form-urlencoded";

            byte[] postDataBytes = Encoding.UTF8.GetBytes(postData);
            request.ContentLength = postDataBytes.Length;

            Stream requestStream = request.GetRequestStream();
            requestStream.Write(postDataBytes, 0, postDataBytes.Length);
            requestStream.Close();

            using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
            {
                StreamReader responseReader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
                var result = responseReader.ReadToEnd();
                responseReader.Close();
                Console.WriteLine(result);
            }
Run Code Online (Sandbox Code Playgroud)

这段代码运行良好但突然抛出异常

System.Net.WebException
Run Code Online (Sandbox Code Playgroud)

异常消息是:基础连接已关闭:发送时发生意外错误.

堆栈跟踪:位于System.Net.HttpWebRequest.GetRequestStream(TransportContext&context)的System.Net.HttpWebRequest.GetRequestStream(),位于CustomerProcessor.Delivery.Deliver(String content,Int32 productCategory,String identifier,String xsltFile)

Exception有一个内部异常:发生异常:System.IO.IOException异常消息是:从传输流中收到意外的EOF或0字节.

堆栈跟踪:System.Net上的System.Net.FixedSizeReader.ReadPacket(Byte []缓冲区,Int32偏移量,Int32计数)处于System.Net的System.Net.Security.SslState.StartReadFrame(Byte []缓冲区,Int32 readBytes,AsyncProtocolRequest asyncRequest).在System.Net.Security.SslState.StartSendBlob(Byte []传入,Int32计数,System.SNet.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken消息,AsyncProtocolRequest asyncRequest)上的Security.SslState.StartReceiveBlob(Byte []缓冲区,AsyncProtocolRequest asyncRequest),位于System.Net.TlsStream.CallProcessAuthentication(对象状态)的System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult)的System.Net.Security.SslState.ForceAuthentication(Boolean receiveFirst,Byte [] buffer,AsyncProtocolRequest asyncRequest)中的AsyncProtocolRequest asyncRequest) …

.net http

15
推荐指数
3
解决办法
3万
查看次数

在WCF客户端的代码中设置消息版本

我想将WSHttpBinding的消息版本设置为EnvelopeVersion.Soap11.我不知道该怎么做.谁能帮我.这是我的绑定代码

var binding = new WSHttpBinding()
        {
            UseDefaultWebProxy = true,
            Security =
            {
                Mode = SecurityMode.Transport,
                Transport =
                {
                    ClientCredentialType = HttpClientCredentialType.Basic
                },
            },
        };
Run Code Online (Sandbox Code Playgroud)

编辑:这是执行此操作的代码

TransportBindingElement transportElement = null;

        transportElement = new HttpsTransportBindingElement();

        ((HttpsTransportBindingElement)transportElement).AuthenticationScheme = AuthenticationSchemes.Basic;
        ((HttpsTransportBindingElement) transportElement).KeepAliveEnabled = false;

        var messegeElement = new TextMessageEncodingBindingElement
        {
            MessageVersion = MessageVersion.CreateVersion(EnvelopeVersion.Soap11, AddressingVersion.None),
            ReaderQuotas =
                    {
                        MaxArrayLength = 200000,
                        MaxBytesPerRead = 200000,
                        MaxDepth = 200000,
                        MaxNameTableCharCount = 200000,
                        MaxStringContentLength = 200000
                    }
        };

        var binding = new CustomBinding(messegeElement, transportElement);
        return binding;
Run Code Online (Sandbox Code Playgroud)

wcf wshttpbinding wcf-client

9
推荐指数
1
解决办法
2万
查看次数

替换XSLT中的特殊字符

我想从XSLT中的字符串中删除字母以外的字符.例如

<Name>O'Niel</Name> = <Name>ONiel</Name>
<Name>St Peter</Name> = <Name>StPeter</Name>
<Name>A.David</Name> = <Name>ADavid</Name>
Run Code Online (Sandbox Code Playgroud)

我们可以在XSLT中使用正则表达式来执行此操作吗?哪种方法可以实现?

编辑:这需要在XSLT 1.0上完成.

string xslt

9
推荐指数
2
解决办法
5万
查看次数

使用WCF的Http请求中缺少授权标头

我正在使用WCF访问Web服务.使用WSHttpBinding,安全模式设置为传输(https),客户端凭据类型为基本.当我尝试使用代理访问服务时,获得401未经授权的异常.

这是绑定

var binding = new WSHttpBinding()
        {
            UseDefaultWebProxy = true,
            Security =
            {
                Mode = SecurityMode.Transport,
                Transport =
                {
                    ClientCredentialType = HttpClientCredentialType.Basic,
                },
            }
        };
Run Code Online (Sandbox Code Playgroud)

这是服务电话

var client = new InternetClient(binding, new EndpointAddress("httpsurl"));

        client.ClientCredentials.UserName.UserName = "username";
        client.ClientCredentials.UserName.Password = "password";
        client.ProcessMessage("somevalue");
Run Code Online (Sandbox Code Playgroud)

使用Http Analyzer CONNECT HEADER查看Http头文件时

(Request-Line):CONNECT somehost.com:443 HTTP/1.1
主机:somehost.com
代理连接:Keep-Alive

POST HEADER

(请求行):POST /Company/1.0 HTTP/1.1
Content-Type:application/soap + xml; charset = utf-8
VsDebuggerCausalityData:uIDPo + voStemjalOv5LtRotFQ7UAAAAAUKLJpa755k6oRwto14BnuE2PDtYKxr9LhfqXFSOo8pEACQAA
主持人:somehost.com
内容长度:898
期望:100-continue
连接:Keep-Alive

如果您看到标题Authorization标头丢失

现在我的问题是为什么WCF调用缺少Authorization标头?我错过了什么吗?.请询问您是否需要更多信息

wcf http-headers

8
推荐指数
3
解决办法
2万
查看次数

为什么我会重构这个代码,因为Cyclomatic Complexity是58

我读过CC 10或更低版本的代码是高度可维护的.但是我写的方法有CC 58.感谢VS 2010代码分析工具.我认为,就我的理解而言,我所写的方法非常简单,易读且易于维护.因此,我不希望重构代码.但由于CC高于可接受的水平,我想知道为什么会重构这种方法.我正在学习如何改进我的代码如果我有错误,请纠正我.这是代码.

private string MapBathRooms(string value)
    {
        double retValue = 0;
        if (value == "1" || value == "One")
            retValue = 1;
        if (value == "OneAndHalf" || value == "1.5" || value == "1 1/2")
            retValue = 1.5;
        if (value == "2" || value == "Two")
            retValue = 2;
        if (value == "TwoAndHalf" || value == "2.5" || value == "2 1/2")
            retValue = 2.5;
        if (value == "3" || value == "Three")
            retValue = 3;
        if (value …
Run Code Online (Sandbox Code Playgroud)

c# cyclomatic-complexity

5
推荐指数
1
解决办法
2108
查看次数

从XmlNode中删除属性

如何从C#中的System.Xml.XmlNode对象中删除属性.我试过的守则不起作用.它抛出异常"要删除的节点是无效的子节点"

foreach (XmlNode distribution 
         in responseXml.SelectNodes("/Distributions/Distribution/DistributionID"))
{
  XmlAttribute attribute = null;
  foreach (XmlAttribute attri in distribution.Attributes)
  {
    if (attri.Name == "GrossRevenue")
      attribute = attri;
  }
  if (attribute != null) 
    distribution.ParentNode.RemoveChild(attribute);
}
Run Code Online (Sandbox Code Playgroud)

c# xml

5
推荐指数
1
解决办法
1万
查看次数

前缀 SOAP XML 而不是直接命名空间

我正在与我们的一位合作伙伴合作整合我们的业务服务。我正在使用 WCF (.Net 3.5) 与合作伙伴 Web 服务进行通信。我认为合作伙伴 Web 服务是用 Java 编写的。

使用 SVC util 我生成了代理类。svcutil 使用 xmlserializer 代替 DataContract 序列化器。但合作伙伴提供的 WSDL 与 Web 服务响应 SOAP xml 不匹配。由于合作伙伴对更改 wsdl 不感兴趣,因此我手动更改了下载的 WSDL 以匹配响应。该问题已得到解决。

现在我遇到了不同的问题。当我向网络服务发送请求时,它总是失败。然后我使用 fiddler 将 SOAP 请求转发给合作伙伴。合作伙伴表示,请求发送的 xml 命名空间未针对其系统进行验证。他们还回复了示例 SOAP 请求。

通过比较这两个请求,命名空间看起来是正确的。但是合作伙伴 xml 使用前缀来定义命名空间,并且元素都带有前缀。而我们这边的 xml 没有前缀,而是直接在父元素中使用命名空间。

这是我们发送的 XML

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <iL21stCentRq xmlns="http://schemas.WebServiceProvider.com/us/ileads/messages/Servicing">
        <ACORD xmlns="http://schemas.WebServiceProvider.com/us/ileads/types/Servicing">
            <SignonRq xmlns="http://www.ACORD.org/standards/PC_Surety/ACORD1/xml/">
                <SignonPswd>
                    <CustId>
                        <SPName>111</SPName>
                    </CustId>
                </SignonPswd>
            </SignonRq>
        </ACORD>
    </iL21stCentRq>
</s:Body>
Run Code Online (Sandbox Code Playgroud)

这是合作伙伴期望我们提供的示例 XML

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:stc="http://schemas.WebServiceProvider.com/us/ileads/messages/Servicing" xmlns:stc1="http://schemas.WebServiceProvider.com/us/ileads/types/Servicing" xmlns:acd="http://www.ACORD.org/standards/PC_Surety/ACORD1/xml/">
<soapenv:Header/>
<soapenv:Body>
    <stc:iL21stCentRq>
        <stc:input>
            <stc1:ACORD>
                <acd:SignonRq> …
Run Code Online (Sandbox Code Playgroud)

wcf namespaces xml-serialization xmlserializer

5
推荐指数
1
解决办法
1万
查看次数

查找所有子元素的最大值并在XSLT中获取其父元素

使用下面的XML,我需要弄清楚哪个人在每个站点工作的时间更长.例如,在下面的XML中,人1在站点1中工作8小时但是人​​2工作仅6小时.因此,结果应包含转换后的XML中的person 1和site 1.如果小时数相等,请选择第一个人.

编辑:我希望使用XSLT 1.0实现.

<root>
    <WorkSite Person="P1" Site="S1">
        <Hours>8</Hours>
    </WorkSite>
    <WorkSite Person="P1" Site="S2">
        <Hours>2</Hours>
    </WorkSite>
    <WorkSite Person="P1" Site="S3">
        <Hours>9</Hours>
    </WorkSite>
    <WorkSite Person="P2" Site="S1">
        <Hours>6</Hours>
    </WorkSite>
    <WorkSite Person="P2" Site="S2">
        <Hours>10</Hours>
    </WorkSite>
    <WorkSite Person="P2" Site="S3">
        <Hours>2</Hours>
    </WorkSite>
</root>
Run Code Online (Sandbox Code Playgroud)

XSLT转换结果应如下所示:

<root> 
    <WorkSite Person="P1" Site="S1"/>  
    <WorkSite Person="P2" Site="S2"/> 
    <WorkSite Person="P1" Site="S3"/> 
</root>
Run Code Online (Sandbox Code Playgroud)

xml xslt

4
推荐指数
1
解决办法
1449
查看次数