小编Fis*_*rdo的帖子

MessageBox中的粗体文本

如何MessageBox.Show使用C#在显示的对话框中以粗体显示文本?

c# messagebox winforms

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

WCF服务主机找不到任何服务元数据

我刚学习wcf,目前已经走到了这一步.

CS档案:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;

namespace wcfLib
{            
    [ServiceContract]
    public interface IfaceService
    {
        [OperationContract]
        int wordLen(string word);
    }

    public class StockService : IfaceService
    {
        public int wordLen(string word)
        {
            return word.Length;
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

然而,当我试图运行它时,它会弹出一个错误:

WCF服务主机找不到任何服务元数据...

知道它可能是什么?

配置文件:

<system.serviceModel>
   <services>
      <service behaviorConfiguration="wcfLib.Service1Behavior" name="wcfLib.Service1">
        <endpoint address="" binding="wsHttpBinding" contract="wcfLib.ser">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8732/Design_Time_Addresses/wcfLib/Service1/" />
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="wcfLib.Service1Behavior"> …
Run Code Online (Sandbox Code Playgroud)

c# wcf

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

(|)和(||)之间有什么区别?

Javascript |||Javascript有什么区别?

而且,&和之间有什么区别&&

javascript operators

18
推荐指数
2
解决办法
7898
查看次数

使用Page.ClientScript.RegisterClientScriptBlock不起作用

我试图点击弹出如下所示,但它不起作用.请帮忙

public void btnSubmit_Click(Object o, EventArgs e)
{
    if (checkFileExists(Convert.ToString(fileInfo)))
    {
        Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "Msg", "<script type=\"text/javascript\"  language=\"javascript\">function showMsg(){return confirm(\"This image name already exists, do you want to replace it?\");}</script>", true);
        btnSubmit.OnClientClick = "return showMsg()";
    }
    if (something else)
    {
        // It does whatever is here but never pops the question above
    }
}
Run Code Online (Sandbox Code Playgroud)

在我的按钮上

 <asp:Button class="Button" ID="btnSubmit" CausesValidation="True" Text="SUBMIT" runat="server"
             OnClick="btnSubmit_Click"></asp:Button>
Run Code Online (Sandbox Code Playgroud)

c# asp.net

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

获取"当前"表中的所有行,而不是子表

如何在不获取子表中的行的情况下获取表中的所有行?

var rows = $('tr', tbl);
Run Code Online (Sandbox Code Playgroud)

这将返回所有<tr>标记,包括子表中的所有行.

jquery

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

对集合进行分组并返回字典

我写了一个方法,它收集了一些项目(价格项 - 每个项目都有一个数量和一个代码),然后按代码对它们进行分组,然后返回一个IDictionary,其中键是项目的代码,值是组带有该代码的项目(希望有意义!)

这是方法的实现:

public IDictionary<string, IEnumerable<PriceDetail>> GetGroupedPriceDetails(IEnumerable<PriceDetail> priceDetails)
{
    // create a dictionary to return
    var groupedPriceDetails = new Dictionary<string, IEnumerable<PriceDetail>>();

    // group the price details by code
    var grouping = priceDetails.GroupBy(priceDetail => priceDetail.Code);

    // foreach grouping, add the code as key and collection as value to the dictionary
    foreach (var group in grouping)
    {
        groupedPriceDetails.Add(group.Key, group);
    }

    // return the collection
    return groupedPriceDetails;
}
Run Code Online (Sandbox Code Playgroud)

然后我尝试重构这个使用ToDictionary,如下所示:

// group the price details by code and return
return priceDetails.GroupBy(priceDetail => priceDetail.Code) …
Run Code Online (Sandbox Code Playgroud)

.net c# linq refactoring

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

无法捕获托管代码中的本机异常

我有一个混合的.NET和本机代码控制台应用程序.由于Visual C RunTime Library致命错误,应用程序进程终止.即使我使用以下内容,托管代码也不会捕获本机异常:

  1. 尝试/捕获块
  2. AppDomain.UnHandledExption += ...
  3. RuntimeCompatibilityAttribute(WrapNonExceptionThrows = true)在AssmblyInfo文件中标记.

我还可以做些什么?

.net c# exception-handling

17
推荐指数
1
解决办法
4646
查看次数

"高凝聚力"是"单一责任原则"的同义词吗?

高内聚的代名词单一职责原则?如果没有,它们有何不同?

oop cohesion

15
推荐指数
2
解决办法
2925
查看次数

如何限制对WCF中某些方法的访问?

我开始使用简单的WCF服务时有点失落.我有两种方法,我想向世界公开一个,第二个我想限制某些用户.最终,我希望能够使用客户端应用程序来使用受限制的方法.到目前为止,我可以匿名访问这两种方法:

C#代码

namespace serviceSpace
{
    [ServiceContract]
    interface ILocationService
    {
        [OperationContract]
        string GetLocation(string id);

        [OperationContract]
        string GetHiddenLocation(string id);
    }

    [AspNetCompatibilityRequirements(
     RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    public class LocationService : ILocationService
    {
        [WebGet(UriTemplate = "Location/{id}")]
        public string GetLocation(string id)
        {
            return "O hai, I'm available to everyone.";
        }

        // only use this if authorized somehow
        [WebGet(UriTemplate = "Location/hush/{id}")]
        public string GetHiddenLocation(string id)
        {
            return "O hai, I can only be seen by certain users.";
        }


    }
}
Run Code Online (Sandbox Code Playgroud)

组态

<?xml version="1.0"?>
<configuration>
  <system.web>
    <compilation debug="true" …
Run Code Online (Sandbox Code Playgroud)

c# authentication wcf

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

请求失败,HTTP状态为401:未授权

我有一个在我的IIS6(XP专业版SP2)中运行的.NET 2.0网站(VB)和一个托管ASMX Web服务的.NET 3.5(在IIS的ASP.NET选项卡下配置为.NET2).

在Chrome中,我可以调用ASMX并成功调用Web方法.但是,在使用.NET 2.0网站调用代码中的Web方法时,我得到:

请求失败,HTTP状态为401:未授权.

我该如何解决这个问题?

web-services .net-3.5 http-status-code-401

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