为什么这个特定的图像导致我的应用程序崩溃与OutOfMemoryException?

我用一个简单的窗口创建了一个非常简单的WPF Windows应用程序:
<Window x:Class="DeleteMe.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<Image Source="C:\Path\To\The\Image\MyImage.png" RenderOptions.BitmapScalingMode="Fant"></Image>
</Grid>
</Window>
Run Code Online (Sandbox Code Playgroud)
Fant和HighQuality位图缩放模式下会出现此问题.这是一个问题的原因是我不想重新调整我们从创建这些图像的人那里获得的每个图像.我正在使用Paint.Net来处理图像.
谢谢.
我的事件查看器给了我以下内容:
Application: DeleteMe.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.OutOfMemoryException
Stack:
at System.Windows.Media.Composition.DUCE+Channel.SyncFlush()
at System.Windows.Interop.HwndTarget.UpdateWindowSettings(Boolean, System.Nullable`1
<ChannelSet>)
at System.Windows.Interop.HwndTarget.UpdateWindowPos(IntPtr)
at System.Windows.Interop.HwndTarget.HandleMessage(MS.Internal.Interop.WindowMessage, IntPtr, IntPtr)
at System.Windows.Interop.HwndSource.HwndTargetFilterMessage(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
at MS.Win32.HwndWrapper.WndProc(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(System.Object)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(System.Object, …Run Code Online (Sandbox Code Playgroud) 我有一个MVVM自助服务终端应用程序,当它在一段时间内处于非活动状态时我需要重新启动.我正在使用Prism和Unity来促进MVVM模式.我重新启动了,我甚至知道如何处理计时器.我想知道的是如何知道什么时候发生了活动,即任何鼠标事件.我知道如何做到这一点的唯一方法是订阅主窗口的预览鼠标事件.这打破了MVVM的想法,不是吗?
我已经考虑将我的窗口暴露为将这些事件暴露给我的应用程序的接口,但这需要窗口实现该接口,这似乎也打破了MVVM.
我正在寻找一种将1300 PDF文档批量转换为XPS文档的廉价方法.我知道我可以用这种格式打印它们,但这需要很长时间.有没有办法在C#中以编程方式执行此操作?
是IServiceProvider基本上只是对任何IOC容器的通用接口,或者是用于特定的框架?我正在滚动我自己的轻量级IOC容器,我想知道我是否应该实现它.我应该实现其他任何接口吗?我对MEF或Unity都不感兴趣.我已广泛使用它们并且它们并不适用于我当前的项目.
我有一个简单的 WPF 页面,其中有一个文本框字段,我的客户希望在页面显示时突出显示该字段。在后面的代码中,它将是三行,但我正在通过 MVVM(我开始认为它有点被高估了)。我已经尝试了许多不同的行为和全局事件变体FocusManager.FocusedElement,但我所做的一切都不会这样做。
最终,我使用的大部分代码都调用了这两行:
Keyboard.Focus(textBox);
textBox.SelectAll();
Run Code Online (Sandbox Code Playgroud)
但无论我把这些行放在哪里,文本框都只聚焦;未选择任何文本。我从来没有在这么简单的事情上遇到过这么多麻烦。我已经在互联网上打了两个小时的头。有谁知道如何做到这一点?
同样,我想要做的就是让文本框获得焦点,并且在导航到页面时选择所有文本。请帮忙!
当我创建一个全新的 create-react-app 并运行命令时,yarn add electron --dev出现以下错误。
RequestError: unable to get local issuer certificate
at ClientRequest.<anonymous> (C:\my-stuff\create-react-test\node_modules\got\source\request-as-event-emitter.js:178:14)
at Object.onceWrapper (events.js:520:26)
at ClientRequest.emit (events.js:412:35)
at ClientRequest.origin.emit (C:\my-stuff\create-react-test\node_modules\@szmarczak\http-timer\source\index.js:37:11)
at TLSSocket.socketErrorListener (_http_client.js:475:9)
at TLSSocket.emit (events.js:400:28)
Run Code Online (Sandbox Code Playgroud)
同样的事情发生在 npm 和 Chocolatey 上,并且只发生在 Electron 上。在其他计算机上不会发生这种情况。我已经完全卸载了节点并重新安装了它。
完成下载模块后会发生这种情况。它正在访问ClientRequest我计算机上的某个位置。我不明白为什么。
我已经在互联网上搜索了好几天寻找解决方案。我已经找到了cnpm解决方案并且它确实有效,但我希望我的项目可以使用npm install或从 git 存储库恢复yarn。现在还不是。我必须从我的 中删除电子package.json,恢复,将其添加回来并调用cnpm命令。
npm config set strict-ssl false<- 该命令没有帮助。
我尝试过单独安装got和@szmarczak\http-timer. 这没有帮助。
在WPF中,如何在隐藏控件时隐藏验证错误模板装饰(默认情况下为红色框)?当我隐藏我的控件(以便于在视图之间切换)时,错误装饰会一直存在.
更难的是,我如何使用MVVM做到这一点?
出于某种原因,以下代码给了我一个例外.
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/PPCa.Common.Infrastructure;component/Skins/Default.xaml"/>
<ResourceDictionary>
<app:ResourceWrapper x:Key="ResourceWrapper" />
<app:NotOperatorValueConverter x:Key="NotOperatorValueConverter" />
</ResourceDictionary>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
Run Code Online (Sandbox Code Playgroud)
这是一个例外:
System.Windows.Markup.XamlParseException occurred
Message=Failed to assign to property 'System.Windows.ResourceDictionary.Source'. [Line: 11 Position: 44]
LineNumber=11
LinePosition=44
StackTrace:
at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
InnerException:
Run Code Online (Sandbox Code Playgroud)
第11行是这样的:
<ResourceDictionary Source="/PPCa.Common.Infrastructure;component/Skins/Default.xaml"/>
Run Code Online (Sandbox Code Playgroud)
我错误地合并了我的词典吗?
我在UserControlMFC中托管WPF CWnd.它工作得很漂亮我现在需要弄清楚如何用它的父级调整控件的大小.我已经迷上了OnSize,我正在调用GetWindowRect并将结果设置为我的控件,如下所示:
void CChildFrame::OnSize(UINT nType, int cx, int cy)
{
CRect rect;
this->GetWindowRect(&rect);
m_mainControl->Width = rect.Width();
m_mainControl->Height = rect.Height();
}
Run Code Online (Sandbox Code Playgroud) 我有这个JSON:
{
"CutCenterId":1,
"Name":"Demo Cut Center",
"Description":"Test",
"IsAvailable":true,
"E2CustomerId":"110000",
"NumberOfMachines":2,
"Machines":[]
}
Run Code Online (Sandbox Code Playgroud)
我有以下POCO:
public class CutCenter
{
int CutCenterId { get; set; }
string Name { get; set; }
string Description { get; set; }
bool IsAvailable { get; set; }
string E2CustomerId { get; set; }
int NumberOfMachines { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
我尝试以下代码行,其中json设置为上面的JSON并且_cutCenter是一个成员变量.
_cutCenter = JsonConvert.DeserializeObject<CutCenter>(json);
Run Code Online (Sandbox Code Playgroud)
在此之后_cutCenter设置为所有默认值.为什么?我究竟做错了什么?