小编Ash*_*shu的帖子

在WCF服务中处理异常的最佳方法是什么?

我在两台或多台远程计算机上部署了WCF服务,并且客户端使用基于桌面的应用程序来访问任何wcf服务.

WCF服务连接到SQL Server 2005以读取和写入数据. 这是一个Intranet场景,其中客户端应位于同一域中.

现在可能存在wcf服务抛出异常的情况:

  1. 无效的网址
  2. WCF服务已关闭
  3. SQL Server 2005未​​运行
  4. 客户端不在同一个域中
  5. 验证失败
  6. 授权失败

和许多其他例外.

对于每个异常,我都必须执行某些操作或更新状态栏,具体取决于异常.例如,如果授权失败,我必须提示用户重新输入其凭据.

请建议最好的设计方法来处理这个问题.

wcf

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

BeginInvoke和Thread.Start之间的区别

我有一个基于对话框的应用程序,我将I/O操作读写委托给不同的线程.

我只想清楚两种方法之间有什么区别..

第一种方法:(我这样做,我的主要形式-Form.cs)

delegate void Action();
Action _action = new Action(Method);
this.BeginInvoke(_action);
Run Code Online (Sandbox Code Playgroud)

第二种方法:

Thread th = new  Thread( new ThreadStart(_action));
th.Start();
Run Code Online (Sandbox Code Playgroud)

我注意到BeginInvoke将UI挂起一秒钟,而第二种方法却没有.

请帮忙

.net c# multithreading delegates

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

在Sql连接字符串中Trusted = yes/no是什么意思?

在Sql连接字符串中Trusted = yes/no是什么意思?

我正在创建一个连接字符串,如下所示:

            string con= string.Format(
                "user id=admin;password=admin;server={0};Trusted_Connection=yes;database=dbtest;connection timeout=600",
                _sqlServer);
Run Code Online (Sandbox Code Playgroud)

请帮忙

c# ado.net sql-server-2005

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

Web服务和远程处理有什么区别?

我知道Web服务并且对远程处理有一些了解.这两个概念都在客户机上调用方法,所以区别在哪里?

通过远程处理我们也可以在远程机器上执行该方法,同样的功能也可以通过Web服务实现.

如果这是一个明显的问题,请原谅我..

.net c# wcf web-services .net-remoting

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

如何在运行时通过URL使用WCF Web服务?

我想通过URL访问服务中公开的所有方法.如果假设URL将是:

http://localhost/MyService/MyService.svc
Run Code Online (Sandbox Code Playgroud)

我如何访问方法:

  1. 如果我想有一个ServiceReference
  2. 如果没有服务参考,我该怎么办?

wcf wcf-binding wcf-client

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

如何从Web服务(WCF)公开我的集合

我有一个自定义集合,我想从WCF Web服务公开.

[DataContract( Name = "MyClass")]
public class MyCollection : IDisposable, List<MyClass> 
{
}
Run Code Online (Sandbox Code Playgroud)

当我使用[DataContract( Name = "MyClass")]属性时,它会给出错误

类型MyCollection是一种无效的集合类型,因为它具有DataContractAttribute属性.

wcf

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

如何在.NET中加密字符串?

我必须加密/解密Xml文件中的一些敏感信息?是的我可以通过编写自己的自定义算法来做到这一点.我想知道在.NET中是否已经有一种内置方式可以做到这一点以及我总是需要注意哪些方面......

.net c# encryption cryptography

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

WPF中的Grid Splitter问题

我想要一个像VS 2008这样的布局.我想要两列和第二列再分成两列.

我在下面提到的xaml中做到了这一点,但是GridSplitter垂直不可见(分割两列).

我希望这两个GridSplitters都可以调整大小.一个GridSplitter调整左手窗格和右手窗格的GridSplitter大小,另一个调整子网格的顶部窗格和右窗格的大小.

第二个GridSplitter是通过这个XAML,但我无法生成拆分右手窗格和左手窗格的XAML代码..请帮助!!

<Window x:Class="AlarmUI_2.Window1"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Window1" Height="300" Width="300">
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>
        <StackPanel Background="Aqua" Grid.Column="0" >
            <TextBlock FontSize="35" Foreground="#58290A" 
                       TextWrapping="Wrap">Left Hand Side</TextBlock>
        </StackPanel>
        <GridSplitter Grid.Column="0" ResizeDirection="Auto" 
                      Grid.RowSpan="1" 
                      HorizontalAlignment="Stretch" 
                      VerticalAlignment="Center"/>
        <Grid Grid.Column="1">
            <Grid.RowDefinitions>            
                <RowDefinition Height="*" />
                <RowDefinition Height="*" />
            </Grid.RowDefinitions>
            <ListBox Grid.Row="0" Background="Red">
                <ListBoxItem>Hello</ListBoxItem>
                <ListBoxItem>World</ListBoxItem>
            </ListBox>
            <GridSplitter Grid.Row="1" Height="5" Background="Gray"
                          VerticalAlignment="Top" HorizontalAlignment="Stretch" />
            <ListBox Grid.Row="1" Background="Violet" Margin="0,5,0,0">
                <ListBoxItem>Hello</ListBoxItem>
                <ListBoxItem>World</ListBoxItem>
            </ListBox>
        </Grid>
    </Grid>
</Window>
Run Code Online (Sandbox Code Playgroud)

wpf wpf-controls gridsplitter

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

实现IList接口

我是仿制药的新手.我想通过从IList<T>接口派生它来实现我自己的集合.

能否请您提供一些实现IList<T>接口的类的链接,或者为我提供至少实现AddRemove方法的代码?

c# generics collections ilist

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

Dependency Property不会更新我的Usercontrol

下面的行适用于TextBox DP Text,其中CellNo是从INotifyPropertychanged派生的类的属性.因此,当我更改CellNo时,文本将被更新,当我更改CellNo时,文本将被更新.这样可以正常工作.

Text="{Binding Path = CellNo, Mode=TwoWay,  UpdateSourceTrigger=PropertyChanged}"
Run Code Online (Sandbox Code Playgroud)

我创建了一个只包含一个TextBox的用户控件.我已经定义了一个DP名称CellValue,如下所示:

public string CellValue
    {
        get { return (string)GetValue(CellValueProperty); }
        set { SetValue(CellValueProperty, value); }
    }

    // Using a DependencyProperty as the backing store for LimitValue.  This enables animation, styling, binding, etc...
    public static readonly DependencyProperty CellValueProperty =
        DependencyProperty.Register("CellValue", typeof(string), typeof(control), new FrameworkPropertyMetadata
        {
            BindsTwoWayByDefault = true,
        });
Run Code Online (Sandbox Code Playgroud)

现在,当我在任何对话框中使用此用户控件并执行与上面相同的绑定时,目标(用户控件内的TextBox)不会更新.

 <local:control
        x:Name="control" 
        CellValue="{Binding Path = CellNo, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
Run Code Online (Sandbox Code Playgroud)

同样在用户控件内部,我将TextBox的Text属性绑定到CellValue DP.

内部用户控制

<TextBox                 
        Text="{Binding Path = CellValue}"
        Name="textBox2" />
Run Code Online (Sandbox Code Playgroud)

我希望当CellValue更改时TextBox文本也应该更新,但是使用上面的appoach它仍然是空白的.

wpf binding dependency-properties

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