小编bam*_*ams的帖子

为我配置"使用端点配置服务"演示失败(Microsoft/endpoint.tv/Pluralsight)

我正在尝试跟随初学者的演示视频到MSDN上的WCF页面.

第一个视频或多或少都很好.我现在正走向第二个视频的结尾.我正在使用VS2010/.NET 4.0,而视频似乎使用的是VS2008(我假设是.NET 3.5,但我不记得).

我正在使用以下演示

我们刚刚添加了3个端点:一个普通的http,net.tcp和net.pipe.当我现在尝试运行项目时,Web服务无法启动.

System.InvalidOperationException: Cannot load the X.509 certificate identity specified in the configuration.
   at System.ServiceModel.Description.ConfigLoader.LoadIdentity(IdentityElement element)
   at System.ServiceModel.Description.ConfigLoader.LoadServiceDescription(ServiceHostBase host, ServiceDescription description, ServiceElement serviceElement, Action`1 addBaseAddress)
   at System.ServiceModel.ServiceHostBase.LoadConfigurationSectionInternal(ConfigLoader configLoader, ServiceDescription description, ServiceElement serviceSection)
   at System.ServiceModel.ServiceHostBase.LoadConfigurationSectionInternal(ConfigLoader configLoader, ServiceDescription description, String configurationName)
   at System.ServiceModel.ServiceHostBase.ApplyConfiguration()
   at System.ServiceModel.ServiceHostBase.InitializeDescription(UriSchemeKeyedCollection baseAddresses)
   at System.ServiceModel.ServiceHost.InitializeDescription(Type serviceType, UriSchemeKeyedCollection baseAddresses)
   at System.ServiceModel.ServiceHost..ctor(Type serviceType, Uri[] baseAddresses)
   at Microsoft.Tools.SvcHost.ServiceHostHelper.CreateServiceHost(Type type, ServiceKind kind)
   at Microsoft.Tools.SvcHost.ServiceHostHelper.OpenService(ServiceInfo info)
Run Code Online (Sandbox Code Playgroud)

基于我的Google fu,我遇到了这个帖子:"无法加载配置中指定的X.509证书标识"

我真的不想参与证书,因为我还在尝试基础知识,所以我按照该帖子中的建议添加<dns value="localhost" />标签.异常更改:

Please try changing the …
Run Code Online (Sandbox Code Playgroud)

wcf exception-handling wcf-configuration x509 wcf-endpoint

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

按下按钮时打开的模式窗口关闭,即使没有调用Close()

我正在编写一个基本上在后台运行的Windows应用程序,其中包含一个与之交互的通知图标.通知图标可以执行基本操作,例如退出应用程序或显示有关它的信息.它还可以启动模态配置对话框.

创建对话框的代码非常简单:

using(var frmSettings = new SettingsForm(configuration))
{
    frmSettings.ConfigurationChanged += ConfigurationChangedHandler;
    frmSettings.UnhandledException += UnhandledExceptionHandler;

    frmSettings.ShowDialog();
}
Run Code Online (Sandbox Code Playgroud)

SettingsForm类主要有3所GroupBox控制,具有LabelTextBox控制在每个和4个Button控制在底部:"Advanced...","Restore Defaults","Cancel",和"Apply".每个TextBox都有一个Validating通过设计器连接的事件处理程序.每个按钮都有一个Click通过设计器连接的处理程序.它们中的每一个都做了非常明显的事情:打开另一个具有更高级设置的模态对话框,将文本框恢复为默认值,关闭对话框或保存更改,触发ConfigurationChanged事件,然后关闭对话框(但仅当所有字段都是有效!).

当表单输入错误时,我Validating通过设置取消相应的事件((CancelEventArgs)e).Cancel = true.但是,两种表单的默认行为是防止用户在验证失败时更改焦点.我发现这很烦人,最终发现设计师中的选项仍然会在用户离开字段时自动验证,但即使验证失败也允许它们离开:AutoValidate = EnableAllowFocusChange.[1]

我的"Apply"按钮Click处理程序基本看起来像这样

private void btnApply_Click(object sender, EventArgs e)
{
    try
    {
        if(this.ValidateChildren())
        {
            this.Configuration.Field1 = this.txtField1.Text;
            this.Configuration.Field2 = this.txtField2.Text;
            this.Configuration.Field3 …
Run Code Online (Sandbox Code Playgroud)

c# winforms

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