小编era*_*zap的帖子

我在哪里可以找到WcfTestClient.exe(Visual Studio的一部分)

MSDN文档的状态,我可以找到WCF测试客户端中:

C:\ Program Files\Microsoft Visual Studio 9.0\Common7\IDE \

但似乎有很多东西从那里丢失,包括WcfTestClient.exe.

我需要安装什么?

wcf visual-studio-2008 visual-studio

145
推荐指数
8
解决办法
16万
查看次数

由于启动用户实例的进程失败,无法生成SQL Server的用户实例.连接将被关闭

我试图在asp.net网络应用程序中为项目添加"基于服务的数据库"(.mdf).从那里我开始尝试创建实体框架模型文件(.edmx).

这样做时我得到错误:

连接到数据库时发生错误.数据库可能不可用.发生了'System.Data.SqlClient.SqlException'类型的异常.错误消息是:'由于启动用户实例的进程失败而无法生成SQL Server的用户实例.连接将被关闭.'.

我的机器上安装了SQL Server 2008 R2 Express版本.

任何想法都将非常感激.

asp.net sql-server-express

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

如何在运行时更改CurrentCulture?

我需要根据每种文化的资源文件在运行时更改文化.

我需要根据指定.resx文件的两种文化来更改表单中控件的属性

resorces1.aspx.resx // default 
resorces1.aspx.he-IL.resx // hebrew culture 
Run Code Online (Sandbox Code Playgroud)

我可以使用fallback资源加载页面,或者在pageload上提供UICulture = "he-IL"值,并且可以使用所需资源加载.

问题是我需要在运行时进行这些更改.

1 ..在我更改按钮单击事件的值后

    btn_change_Click(....)
    {
        UICulture = "he-IL" ;
    }
Run Code Online (Sandbox Code Playgroud)

它仍然返回到"en-US"的初始值

如何在运行时提交对UICulture的更改?

2 ..如果我不知道它是"en-US",我如何引用回退资源文件?

c# asp.net culture

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

元数据覆盖和基本元数据必须属于同一类型

我试图在派生类中覆盖ItemsControl.ItemsSourceProperty的元数据,以便分配我自己的回调:

 public class CustomDataGrid : System.Windows.Controls.DataGrid
 {
    static CustomDataGrid()
    {
        CustomDataGrid.ItemsSourceProperty.OverrideMetadata(typeof(CustomDataGrid), new UIPropertyMetadata(new PropertyChangedCallback(OnItemsSourcePropertyChanged)));
    }

    private static void OnItemsSourcePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
    {}
 }
Run Code Online (Sandbox Code Playgroud)

我得到一个设计师+运行时异常:

Metadata override and base metadata must be of the same type
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么 ?

wpf metadata custom-controls

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

指针与参考返回类型

我试图想出一个具体的推理,为什么要在引用上使用指针作为函数的返回类型,

我的理由是,如果无意中将null值返回给引用类型,则无法检查它,并可能导致运行时错误

  int& something(int j)
  {
      int* p = 0 ;  
      return *p;
  }

  void main()
  {
      int& i = something(5);
      i = 7;   // run-time error 
  }
Run Code Online (Sandbox Code Playgroud)

如果我使用了指针,我可以检查它并避免错误,指针返回值将作为合同,必须返回一个值.

 void main()
 {
         int* i = something(5);
         if( i != null )
             *i = 7;
 }
Run Code Online (Sandbox Code Playgroud)

任何想法将再次受到赞赏,

你会用什么以及为什么引用或指针

提前致谢.

c++ pointers reference

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

服务''没有应用程序(非基础结构)端点

我一直得到一个无法解释的例外

 Service 'EmployeeManagerImplementation.EmployeeManagerService' has zero application (non-infrastructure) 
 endpoints. This might be because no configuration file was found for your application, 
 or because no service element matching the service name could be found in the configuration file,   or because no endpoints were defined in the service element.
Run Code Online (Sandbox Code Playgroud)

我遇到过解决这个问题的其他帖子,但似乎没有人有一个确切的答案,而且他们的解决方案没有为我工作.

服务没有应用程序(非基础结构)端点

这里的任何方式都是我的app.config

 <system.serviceModel>
    <services>
        <service name="Some.Test.EmployeeManagerService">
            <endpoint address="net.tcp://localhost:8080/Service" binding="netTcpBinding"
                bindingConfiguration="" contract="Contracts.IEmployeeManagerService" />
            <endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange"/>
        </service>
    </services>
</system.serviceModel>
Run Code Online (Sandbox Code Playgroud)

我的合同:

[ServiceContract(Namespace="Some.Test")]
public interface IEmployeeManagerService
{
    [OperationContract]
    string Test();    
}
Run Code Online (Sandbox Code Playgroud)

我的服务:

public class EmployeeManagerService …
Run Code Online (Sandbox Code Playgroud)

wcf

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

正则表达式检查字符串中间的空白区域

我想验证字符是字母数字:

Regex aNum = Regex("[a-z][A-Z][0-9]");
Run Code Online (Sandbox Code Playgroud)

我想添加可能有空格的选项,因此它将是一个双字表达式:

Regex aNum = Regex("[a-z][A-Z][0-9]["\\s]");
Run Code Online (Sandbox Code Playgroud)

但找不到正确的语法.

id适用于任何煽动.

c# regex whitespace

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

WPF主题最佳实践

这是一个最佳实践关于WPF问题更换主题皮肤,更具体剥皮.这更像是一个基于意见的问题,因为我没有问题使这项工作,但更多的是一般想知道我的结论是否涵盖所有情景,以及是否有其他人在这个问题上遇到相同的想法,他们是什么方法.

一些背景,我们的团队需要定义一种方法,使我们的系统能够成为主题.

我们将此功能分为两类:

1)我们的控件的样式,我们简称为" 主题 ".

2)用于定制其外观的资源称为" 皮肤 ",包括画笔,以及各种尺寸结构,如CornerRadius,BorderThickness等.

为系统设置外观的方法是将皮肤字典最后合并到应用程序资源中的简单情况.

  <Application.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="Default.skin.xaml" />
            <ResourceDictionary Source="Theme.xaml" />
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</Application.Resources>
Run Code Online (Sandbox Code Playgroud)

一个不同的皮肤最后合并到我们的应用程序.

  protected override void OnStartup(StartupEventArgs e)
  {
       base.OnStartup(e);

       string skin = e.Args[0];
       if (skin == "Blue")
       {         .
            ResourceDictionary blueSkin = new ResourceDictionary();
            blueSkin.Source = new Uri("Blue.skin.xaml", UriKind.Relative);

            Application.Current.Resources.MergedDictionaries.Add(blueSkin);
       }
  }
Run Code Online (Sandbox Code Playgroud)

Inside Theme.xaml:

   <!-- Region TextBox ControlTemplate -->

<ControlTemplate TargetType="{x:Type TextBox}" x:Key="TextBoxTemplate">
    <Border  Background="{TemplateBinding Background}"  
         BorderBrush="{TemplateBinding BorderBrush}" 
         BorderThickness="{TemplateBinding BorderThickness}"
         CornerRadius="{StaticResource …
Run Code Online (Sandbox Code Playgroud)

wpf resources themes styles

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

暴露net.tcp端点

我对如何在WCF中公开端点感到困惑

我有一个tcp端点和一个mex tcp端点.

<service name="MessageReaderService.MessageReaderService">
    <endpoint name="NetTcpReaderService" 
        address="ReaderService" 
        binding="netTcpBinding" bindingConfiguration=""
        contract="Contracts.IMessageReaderService" />
    <endpoint name="netTcpMex" 
        address="mex" 
        binding="mexTcpBinding" bindingConfiguration=""
        contract="IMetadataExchange" />
    <host>
       <baseAddresses>
           <add baseAddress="net.tcp://localhost:8082" />
       </baseAddresses>
    </host>
 </service>
Run Code Online (Sandbox Code Playgroud)

当我尝试在服务主机中运行它时,我得到以下异常:

在服务MessageReaderService实现的合同列表中找不到合同名称"IMetadataExchange".将ServiceMetadataBehavior
直接添加到配置文件或ServiceHost以启用对此合同的支持.

所以我从这个错误中得出结论,我需要添加一个服务行为来公开元数据.

所以我添加了这个行为:

<behavior name="ServiceBehavior">
    <serviceMetadata httpGetEnabled="true"/>                  
</behavior> 
Run Code Online (Sandbox Code Playgroud)

但后来我得到了一个不同的错误:

ServiceMetadataBehavior的HttpGetEnabled属性设置为true,HttpGetUrl属性是相对地址,但没有http基址.提供http基址或将HttpGetUrl设置为绝对地址.

  1. 所以现在我必须实际添加另一个端点(http)以通过mexhttpbinding公开元数据?
  2. 是否有一种通过tcp公开端点的简单方法?

c# wcf

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

绑定到另一个控件的DataContext的属性

我在应用游戏中获得了2个面板

它们都受到不同元素的束缚.

    GameDetailsPanel.DataContext = game ;

    GameBoardPanel.DataContext = gameBoard ;
Run Code Online (Sandbox Code Playgroud)

*游戏有Turn Property*.

    public Class Game 
    {
        public bool Turn{ get; set;}             
    } 
Run Code Online (Sandbox Code Playgroud)

现在我需要将GameBoardPanel中的一个绑定到Property Turn的值,

*例如:类似*的东西

   <Button Fill={Binding Source=GameDetailsPanel.DataContext , Path=Turn } ></Button>
Run Code Online (Sandbox Code Playgroud)

我如何在绑定中引用GameDetailsPanel.DataContext?

data-binding wpf

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