创建对话框时,软件将冻结100秒。当对话框创建对话框时,我设法通过附加到软件并打破呼吸箱来获取呼叫储备。看起来WPF正在使用100秒的超时进行WebRequest,但我不明白为什么。我们在代码中不做任何Web Requests,而是以某种方式决定必须进行WebRequest。 diD有人遇到类似的问题,或者可以想象为什么每次打开此对话框时都会发生这个呼叫?任何提示都可能有帮助...
callstack:
file:///C:/Windows/system32/spool/drivers/color/sRGB%20Color%20Space%20Profile.icm
TimeOut 100000
ntdll.dll!00007fffc8f246d4() Unknown
KernelBase.dll!00007fffc653f310() Unknown
WindowsBase.ni.dll!00007fff7073069e() Unknown
[Managed to Native Transition]
WindowsBase.dll!System.Windows.Threading.DispatcherSynchronizationContext.Wait(System.IntPtr[] waitHandles, bool waitAll, int millisecondsTimeout) Unknown
[Native to Managed Transition]
[Managed to Native Transition]
mscorlib.dll!System.Threading.WaitHandle.InternalWaitOne(System.Runtime.InteropServices.SafeHandle waitableSafeHandle, long millisecondsTimeout, bool hasThreadAffinity, bool exitContext) Unknown
mscorlib.dll!System.Threading.WaitHandle.WaitOne(int millisecondsTimeout, bool exitContext) Unknown
System.dll!System.Net.FileWebRequest.GetResponse() Unknown
> PresentationCore.dll!MS.Internal.WpfWebRequestHelper.GetResponse(System.Net.WebRequest request) Unknown
PresentationCore.dll!System.Windows.Media.ColorContext.Initialize(System.Uri profileUri, bool isStandardProfileUriNotFromUser) Unknown
PresentationCore.dll!System.Windows.Media.ColorContext.ColorContext(System.Windows.Media.PixelFormat pixelFormat) Unknown
PresentationCore.dll!System.Windows.Media.Imaging.BitmapSource.CreateCachedBitmap(System.Windows.Media.Imaging.BitmapFrame frame, System.Windows.Media.Imaging.BitmapSourceSafeMILHandle wicSource, System.Windows.Media.Imaging.BitmapCreateOptions createOptions, System.Windows.Media.Imaging.BitmapCacheOption cacheOption, System.Windows.Media.Imaging.BitmapPalette palette) Unknown
PresentationCore.dll!System.Windows.Media.Imaging.BitmapFrameDecode.FinalizeCreation() Unknown
PresentationCore.dll!System.Windows.Media.Imaging.BitmapDecoder.SetupFrames(System.Windows.Media.Imaging.BitmapDecoder decoder, System.Collections.ObjectModel.ReadOnlyCollection<System.Windows.Media.Imaging.BitmapFrame> frames) Unknown
PresentationCore.dll!System.Windows.Media.Imaging.BitmapDecoder.Frames.get() Unknown
PresentationCore.dll!System.Windows.Media.Imaging.BitmapFrame.CreateFromUriOrStream(System.Uri baseUri, System.Uri uri, System.IO.Stream stream, System.Windows.Media.Imaging.BitmapCreateOptions createOptions, System.Windows.Media.Imaging.BitmapCacheOption cacheOption, System.Net.Cache.RequestCachePolicy uriCachePolicy) Unknown
PresentationCore.dll!System.Windows.Media.ImageSourceConverter.ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) Unknown
PresentationFramework.dll!System.Windows.TemplateContent.TrySharingValue(System.Windows.DependencyProperty property, object value, string parentName, System.Xaml.XamlReader xamlReader, bool allowRecursive, out System.Windows.PropertyValue? sharedValue) Unknown
PresentationFramework.dll!System.Windows.TemplateContent.TrySharingProperty(System.Xaml.XamlReader xamlReader, System.Xaml.XamlType parentType, string parentName, MS.Utility.FrugalObjectList<System.Xaml.NamespaceDeclaration> previousNamespaces, out System.Windows.PropertyValue? sharedValue) Unknown
PresentationFramework.dll!System.Windows.TemplateContent.ParseNode(System.Xaml.XamlReader xamlReader, System.Windows.TemplateContent.StackOfFrames stack, System.Collections.Generic.List<System.Windows.PropertyValue> sharedProperties, ref int nameNumber, out object newValue) Unknown
PresentationFramework.dll!System.Windows.TemplateContent.ParseNodes(System.Windows.TemplateContent.StackOfFrames stack, System.Collections.Generic.List<System.Windows.PropertyValue> sharedProperties, ref int nameNumber) Unknown
PresentationFramework.dll!System.Windows.TemplateContent.ParseTree(System.Windows.TemplateContent.StackOfFrames stack, System.Collections.Generic.List<System.Windows.PropertyValue> sharedProperties, ref int nameNumber) Unknown
PresentationFramework.dll!System.Windows.TemplateContent.ParseXaml() Unknown
PresentationFramework.dll!System.Windows.FrameworkTemplate.Template.set(System.Windows.TemplateContent value) Unknown
System.Xaml.dll!MS.Internal.Xaml.Runtime.ClrObjectRuntime.SetValue(object inst, System.Xaml.XamlMember property, object value) Unknown
System.Xaml.dll!System.Xaml.XamlObjectWriter.Logic_ApplyPropertyValue(MS.Internal.Xaml.Context.ObjectWriterContext ctx, System.Xaml.XamlMember prop, object value, bool onParent) Unknown
System.Xaml.dll!System.Xaml.XamlObjectWriter.Logic_DoAssignmentToParentProperty(MS.Internal.Xaml.Context.ObjectWriterContext ctx) Unknown
System.Xaml.dll!System.Xaml.XamlObjectWriter.WriteEndMember() Unknown
PresentationFramework.dll!System.Windows.Markup.WpfXamlLoader.TransformNodes(System.Xaml.XamlReader xamlReader, System.Xaml.XamlObjectWriter xamlWriter, bool onlyLoadOneNode, bool skipJournaledProperties, bool shouldPassLineNumberInfo, System.Xaml.IXamlLineInfo xamlLineInfo, System.Xaml.IXamlLineInfoConsumer xamlLineInfoConsumer, MS.Internal.Xaml.Context.XamlContextStack<System.Windows.Markup.WpfXamlFrame> stack, System.Windows.Markup.IStyleConnector styleConnector) Unknown
PresentationFramework.dll!System.Windows.Markup.WpfXamlLoader.Load(System.Xaml.XamlReader xamlReader, System.Xaml.IXamlObjectWriterFactory writerFactory, bool skipJournaledProperties, object rootObject, System.Xaml.XamlObjectWriterSettings settings, System.Uri baseUri) Unknown
PresentationFramework.dll!System.Windows.ResourceDictionary.CreateObject(System.Windows.Baml2006.KeyRecord key) Unknown
PresentationFramework.dll!System.Windows.ResourceDictionary.OnGettingValue(object key, ref object value, out bool canCache) Unknown
PresentationFramework.dll!System.Windows.ResourceDictionary.OnGettingValuePrivate(object key, ref object value, out bool canCache) Unknown
PresentationFramework.dll!System.Windows.ResourceDictionary.GetValueWithoutLock(object key, out bool canCache) Unknown
PresentationFramework.dll!System.Windows.ResourceDictionary.GetValue(object key, out bool canCache) Unknown
PresentationFramework.dll!System.Windows.DeferredResourceReference.GetValue(System.Windows.BaseValueSourceInternal valueSource) Unknown
PresentationFramework.dll!System.Windows.StaticResourceExtension.TryProvideValueImpl(System.IServiceProvider serviceProvider, bool allowDeferredReference, bool mustReturnDeferredResourceReference) Unknown
PresentationFramework.dll!System.Windows.StaticResourceExtension.ProvideValueInternal(System.IServiceProvider serviceProvider, bool allowDeferredReference) Unknown
System.Xaml.dll!MS.Internal.Xaml.Runtime.ClrObjectRuntime.CallProvideValue(System.Windows.Markup.MarkupExtension me, System.IServiceProvider serviceProvider) Unknown
System.Xaml.dll!System.Xaml.XamlObjectWriter.Logic_ProvideValue(MS.Internal.Xaml.Context.ObjectWriterContext ctx) Unknown
System.Xaml.dll!System.Xaml.XamlObjectWriter.Logic_AssignProvidedValue(MS.Internal.Xaml.Context.ObjectWriterContext ctx) Unknown
System.Xaml.dll!System.Xaml.XamlObjectWriter.WriteEndMember() Unknown
PresentationFramework.dll!System.Windows.Markup.WpfXamlLoader.TransformNodes(System.Xaml.XamlReader xamlReader, System.Xaml.XamlObjectWriter xamlWriter, bool onlyLoadOneNode, bool skipJournaledProperties, bool shouldPassLineNumberInfo, System.Xaml.IXamlLineInfo xamlLineInfo, System.Xaml.IXamlLineInfoConsumer xamlLineInfoConsumer, MS.Internal.Xaml.Context.XamlContextStack<System.Windows.Markup.WpfXamlFrame> stack, System.Windows.Markup.IStyleConnector styleConnector) Unknown
PresentationFramework.dll!System.Windows.Markup.WpfXamlLoader.Load(System.Xaml.XamlReader xamlReader, System.Xaml.IXamlObjectWriterFactory writerFactory, bool skipJournaledProperties, object rootObject, System.Xaml.XamlObjectWriterSettings settings, System.Uri baseUri) Unknown
PresentationFramework.dll!System.Windows.ResourceDictionary.CreateObject(System.Windows.Baml2006.KeyRecord key) Unknown
PresentationFramework.dll!System.Windows.ResourceDictionary.OnGettingValue(object key, ref object value, out bool canCache) Unknown
PresentationFramework.dll!System.Windows.ResourceDictionary.OnGettingValuePrivate(object key, ref object value, out bool canCache) Unknown
PresentationFramework.dll!System.Windows.ResourceDictionary.GetValueWithoutLock(object key, out bool canCache) Unknown
PresentationFramework.dll!System.Windows.ResourceDictionary.GetValue(object key, out bool canCache) Unknown
PresentationFramework.dll!System.Windows.ResourceDictionary.GetValueWithoutLock(object key, out bool canCache) Unknown
PresentationFramework.dll!System.Windows.ResourceDictionary.GetValue(object key, out bool canCache) Unknown
PresentationFramework.dll!System.Windows.ResourceDictionary.GetValueWithoutLock(object key, out bool canCache) Unknown
PresentationFramework.dll!System.Windows.ResourceDictionary.GetValue(object key, out bool canCache) Unknown
PresentationFramework.dll!System.Windows.ResourceDictionary.Lookup(object key, bool allowDeferredResourceReference, bool mustReturnDeferredResourceReference, bool canCacheAsThemeResource) Unknown
PresentationFramework.dll!System.Windows.StaticResourceExtension.FindResourceInEnviroment(System.IServiceProvider serviceProvider, bool allowDeferredReference, bool mustReturnDeferredResourceReference) Unknown
PresentationFramework.dll!System.Windows.StaticResourceExtension.TryProvideValueImpl(System.IServiceProvider serviceProvider, bool allowDeferredReference, bool mustReturnDeferredResourceReference) Unknown
PresentationFramework.dll!System.Windows.StaticResourceExtension.ProvideValueInternal(System.IServiceProvider serviceProvider, bool allowDeferredReference) Unknown
System.Xaml.dll!MS.Internal.Xaml.Runtime.ClrObjectRuntime.CallProvideValue(System.Windows.Markup.MarkupExtension me, System.IServiceProvider serviceProvider) Unknown
System.Xaml.dll!System.Xaml.XamlObjectWriter.Logic_ProvideValue(MS.Internal.Xaml.Context.ObjectWriterContext ctx) Unknown
System.Xaml.dll!System.Xaml.XamlObjectWriter.Logic_AssignProvidedValue(MS.Internal.Xaml.Context.ObjectWriterContext ctx) Unknown
System.Xaml.dll!System.Xaml.XamlObjectWriter.WriteEndMember() Unknown
PresentationFramework.dll!System.Windows.Markup.WpfXamlLoader.TransformNodes(System.Xaml.XamlReader xamlReader, System.Xaml.XamlObjectWriter xamlWriter, bool onlyLoadOneNode, bool skipJournaledProperties, bool shouldPassLineNumberInfo, System.Xaml.IXamlLineInfo xamlLineInfo, System.Xaml.IXamlLineInfoConsumer xamlLineInfoConsumer, MS.Internal.Xaml.Context.XamlContextStack<System.Windows.Markup.WpfXamlFrame> stack, System.Windows.Markup.IStyleConnector styleConnector) Unknown
PresentationFramework.dll!System.Windows.Markup.WpfXamlLoader.Load(System.Xaml.XamlReader xamlReader, System.Xaml.IXamlObjectWriterFactory writerFactory, bool skipJournaledProperties, object rootObject, System.Xaml.XamlObjectWriterSettings settings, System.Uri baseUri) Unknown
PresentationFramework.dll!System.Windows.Markup.WpfXamlLoader.LoadBaml(System.Xaml.XamlReader xamlReader, bool skipJournaledProperties, object rootObject, System.Xaml.Permissions.XamlAccessLevel accessLevel, System.Uri baseUri) Unknown
PresentationFramework.dll!System.Windows.Markup.XamlReader.LoadBaml(System.IO.Stream stream, System.Windows.Markup.ParserContext parserContext, object parent, bool closeStream) Unknown
Edit:
我在此视图中使用DataTemplate:<DataTemplate DataType="{x:Type shared:PreviewPageViewModel}">
<Grid Background="White">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Image Source="{Binding PreviewPicturePath, Converter={StaticResource StringToImageSourceConverter}}"
Stretch="Uniform"
StretchDirection="Both"
Grid.Row="0"
Visibility="{Binding PicturePathValid, Converter={StaticResource BooleanToVisibilityConverter}}" />
<ContentControl Grid.Row="0"
BorderBrush="DarkGray"
BorderThickness="10"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Content="{Binding Path=FunctionViewAdapter}"
ContentTemplateSelector="{StaticResource HintTemplateSelector}"
Visibility="{Binding ShowFallbackPreview, Converter={StaticResource BooleanToVisibilityConverter}}"
Opacity="0.85">
</ContentControl>
</Grid>
绑定的属性只是一个字符串:
string directory = Path.GetDirectoryName(panelPath);
string panelPicturePath = Path.Combine(directory, "PreviewPicture.png");
if (File.Exists(panelPicturePath))
{
PreviewPicturePath = panelPicturePath;
}
public class StringToImageSourceConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (!(value is string valueString))
{
return null;
}
try
{
ImageSource image = BitmapFrame.Create(new Uri(valueString), BitmapCreateOptions.IgnoreImageCache, BitmapCacheOption.OnLoad);
return image;
}
catch { return null; }
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}确保您没有任何线程池/耗尽问题。 我也有类似的问题。 colorContext尝试读取C:/Windows/System32/spool/drivers/color/srgb颜色空间配置文件。icm,使用wpfwebrequesthelper。同时,另一个WPF控件使用了计时器,该计时器试图调用调度程序。召唤每100ms,但是调度员正在等待WPFWebrequestHelper。这导致了这种情况,其中多个计时器线程(来自线程池)被锁定在dispatcher.invoke上。我想WPFWEBREQUESTHELPER和计时器都试图使用同一线程池,在我的情况下,这只是精疲力尽。我通过避免多个调度程序来修复它。