이것은 사용자로부터 방금보고되었습니다. 이 프로그램의 일부는 테스트되었고 야생에서 상당히 광범위하게 사용되었으며 얼마 동안 변경되지 않았습니다. 그것은 그녀를 위해 일하고 있고 최근에 실패하기 시작한 것 같습니다. 이미지는 자원에서 나오므로 폐기 될 필요는 없습니다. 내 테스트 (및 코드를 검토하여),이 항상 UI 스레드에서 일어나야합니다, 그래서 내 최고의 추측은 프로그램이 어떻게 든 손상된, 실제로 유효하지 않은 리소스의 이미지로 이어지는 것입니다. 그것은 의미가 있으며, 더 그럴듯한 설명이 있습니다."매개 변수가 유효하지 않습니다." 리소스에서 이미지를 설정할 때 예외가 발생했습니다.
Msg: Parameter is not valid.
Source: System.Drawing
Assembly: System.Drawing, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a
Stack: at System.Drawing.Image.get_Width()
at System.Drawing.Image.get_Size()
at System.Windows.Forms.PictureBox.GetPreferredSizeCore(Size
proposedSize)
at System.Windows.Forms.Control.GetPreferredSize(Size proposedSize)
at
System.Windows.Forms.Layout.TableLayout.GetElementSize(IArrangedElement
element, Size proposedConstraints)
at System.Windows.Forms.Layout.TableLayout.InflateColumns(ContainerInfo
containerInfo, Size proposedConstraints, Boolean measureOnly)
at System.Windows.Forms.Layout.TableLayout.ApplyStyles(ContainerInfo
containerInfo, Size proposedConstraints, Boolean measureOnly)
at System.Windows.Forms.Layout.TableLayout.LayoutCore(IArrangedElement
container, LayoutEventArgs args)
at System.Windows.Forms.Layout.LayoutEngine.Layout(Object container,
LayoutEventArgs layoutEventArgs)
at System.Windows.Forms.Control.OnLayout(LayoutEventArgs levent)
at System.Windows.Forms.ScrollableControl.OnLayout(LayoutEventArgs
levent)
at System.Windows.Forms.TableLayoutPanel.OnLayout(LayoutEventArgs levent)
at System.Windows.Forms.Control.PerformLayout(LayoutEventArgs args)
at
System.Windows.Forms.Control.System.Windows.Forms.Layout.IArrangedElement.PerformLayout(IArrangedElement
affectedElement, String affectedProperty)
at System.Windows.Forms.Control.PerformLayout(LayoutEventArgs args)
at
System.Windows.Forms.Control.System.Windows.Forms.Layout.IArrangedElement.PerformLayout(IArrangedElement
affectedElement, String affectedProperty)
at System.Windows.Forms.PictureBox.InstallNewImage(Image value,
ImageInstallationType installationType)
at System.Windows.Forms.PictureBox.set_Image(Image value)
at SayMore.Transcription.UI.OralAnnotationRecorderBaseDlg.UpdateDisplay()
at
SayMore.Transcription.UI.OralAnnotationRecorderBaseDlg.BeginRecording(TimeRange
timeRangeOfSourceBeingAnnotated)
at
SayMore.Transcription.UI.OralAnnotationRecorderBaseDlg.HandleRecordAnnotationMouseDown(Object
sender, MouseEventArgs e)
at
SayMore.Transcription.UI.OralAnnotationRecorderBaseDlg.OnLowLevelKeyDown(Keys
key)
at
SayMore.UI.LowLevelControls.MonitorKeyPressDlg.PreFilterMessage(Message& m)
at System.Windows.Forms.Application.ThreadContext.ProcessFilters(MSG&
msg, Boolean& modified)
at
System.Windows.Forms.Application.ThreadContext.PreTranslateMessage(MSG& msg)
at
System.Windows.Forms.Application.ThreadContext.System.Windows.Forms.UnsafeNativeMethods.IMsoComponent.FPreTranslateMessage(MSG&
msg)
at
System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr
dwComponentID, Int32 reason, Int32 pvLoopData)
at
System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32
reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32
reason, ApplicationContext context)
at System.Windows.Forms.Application.RunDialog(Form form)
at System.Windows.Forms.Form.ShowDialog(IWin32Window owner)
at SayMore.Model.Files.ComponentFile.RecordAnnotations(Form frm,
AudioRecordingType annotationType)
at
SayMore.Transcription.UI.TextAnnotationEditor.<>c_DisplayClassb.<HandleRecordedAnnotationButtonClick>b_a()
at
SayMore.Transcription.UI.TextAnnotationEditor.ShowSegmentationDialog(Action
showDialog)
at
SayMore.Transcription.UI.TextAnnotationEditor.HandleRecordedAnnotationButtonClick(Object
sender, EventArgs e)
at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)
at System.Windows.Forms.ToolStripMenuItem.OnClick(EventArgs e)
at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)
at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)
at System.Windows.Forms.ToolStripItem.FireEventInteractive(EventArgs e,
ToolStripItemEventType met)
at System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e,
ToolStripItemEventType met)
at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)
at System.Windows.Forms.ToolStripDropDown.OnMouseUp(MouseEventArgs mea)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons
button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ToolStrip.WndProc(Message& m)
at System.Windows.Forms.ToolStripDropDown.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg,
그리고 여기에 이미지 설정지고 우리의 코드에서 방법이다 : 다음은 호출 스택의
protected override void UpdateDisplay()
{
_recDeviceIndicator.UpdateDisplay();
_labelListenButton.Image = (_waveControl.IsPlaying && _playingBackUsingHoldDownButton ?
Resources.ListenToOriginalRecordingDown : Resources.ListenToOriginalRecording);
_labelRecordButton.Image = (ViewModel.GetIsRecording() ?
Resources.RecordingOralAnnotationInProgress : Resources.RecordOralAnnotation);
_labelListenButton.Enabled = !ViewModel.GetIsRecording() &&
(ViewModel.CurrentUnannotatedSegment != null || !ViewModel.GetIsFullyAnnotated());
_labelRecordButton.Enabled = (ViewModel.GetSelectedSegmentIsLongEnough() &&
_userHasListenedToSelectedSegment &&
AudioUtils.GetCanRecordAudio(true) &&
!_waveControl.IsPlaying && !ViewModel.GetIsAnnotationPlaying());
_labelListenHint.Visible = _spaceBarMode == SpaceBarMode.Listen && _labelListenButton.Enabled;
_labelRecordHint.Visible = _spaceBarMode == SpaceBarMode.Record && _labelRecordButton.Enabled && !_reRecording && _recordingErrorMessage == null;
if (_spaceBarMode == SpaceBarMode.Done && _recordingErrorMessage == null)
{
if (!_labelFinishedHint.Visible)
{
_pictureIcon.Image = Resources.Green_check;
_labelFinishedHint.Visible = true;
_tableLayoutButtons.Controls.Add(_labelFinishedHint, 1, 0);
_tableLayoutButtons.SetRowSpan(_labelFinishedHint, 3);
AcceptButton = _buttonOK;
}
}
else
{
UdateErrorMessageDisplay();
if (_labelErrorInfo.Visible)
{
_pictureIcon.Image = Resources.Information_red;
if (_labelFinishedHint.Visible)
{
_labelFinishedHint.Visible = false;
_tableLayoutButtons.Controls.Remove(_labelFinishedHint);
}
_labelRecordHint.Visible = false;
}
else
{
_pictureIcon.Image = Resources.Information_blue;
}
float percentage = (_labelErrorInfo.Visible) ? 50 : 100;
_tableLayoutButtons.RowStyles[0].Height = (_labelErrorInfo.Visible) ? percentage : 0;
_tableLayoutButtons.RowStyles[1].Height = (_labelListenHint.Visible) ? percentage : 0;
_tableLayoutButtons.RowStyles[2].Height = (_labelRecordHint.Visible) ? percentage : 0;
}
base.UpdateDisplay();
}
나는 이미지를 설정하는 통화의 예외를 일으키는 확실하지 않다 컨텍스트를 기반으로 _labelRecordButton.Image가 Resources.RecordingOralAnnotationInProgress로 설정되는 곳이라고 생각합니다. 중요한 점은 모든 경우에 Image가 Resources에서 오는 것이므로 항상 유효해야한다는 것입니다.