小编Kai*_*i G的帖子

Source = null的ImageSourceConverter错误

我正在将Image的Source属性绑定到字符串.此字符串可能为null,在这种情况下,我只是不想显示图像.但是,我在Debug输出中得到以下内容:

System.Windows.Data错误:23:无法将类型为"<null>"的"<null>"转换为使用默认转换为"en-AU"文化键入"System.Windows.Media.ImageSource"; 考虑使用Binding的Converter属性.NotSupportedException:'System.NotSupportedException:ImageSourceConverter无法转换(null).位于System.Windows.Media.ImageSourceConverter.ConvertFrom(ITypeDescriptorContext context,CultureInfo culture,Object value)的System.ComponentModel.TypeConverter.GetConvertFromException(Object value)at MS.Internal.Data.DefaultValueConverter.ConvertHelper(Object o,Type destinationType,DependencyObject) targetElement,CultureInfo culture,Boolean isForward)'

我更喜欢这个没有显示,因为它只是噪音 - 是否有任何方法可以抑制它?

.net wpf exception-handling image ivalueconverter

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

Azure表存储中的TimeSpan属性

我有一个实体,其中包含TimeSpan我想要保存在Azure表存储中的属性.当我尝试保存实体时,我收到错误:

无法转换为不支持的类型'TimeSpan'

有没有办法进行自动转换或其他方式支持TimeSpan

.net azure azure-table-storage

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

ASP.Net核心注入设置

在ASP.Net Core中,可以使用命令将配置值注入到类中IOptions<T>.

所以,如果我有以下appsettings.json配置:

{
  "CustomSection": {
    "Foo": "Bar"
  },
  "RootUrl": "http://localhost:12345/"
}
Run Code Online (Sandbox Code Playgroud)

我可以注入IOptions<CustomSection>我的构造函数(假设我已经定义了一个CustomSection类)并读取Foo属性.

如何将RootUrl设置注入构造函数或不支持?

c# asp.net dependency-injection asp.net-core-1.0

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