2013-04-18 7 views
1

내가 옥시 젼 .NET 에서 프로그램을 쓰고 있어요 어떻게 처리하고 nullable 형식 이상한 CLR 오류 동안

namespace RULER; 

interface 

uses 
    System, 
    System.Drawing, 
    System.Collections, 
    System.Collections.Generic, 
    System.Windows.Forms, 
    System.ComponentModel; 

type 
    /// <summary> 
    /// Summary description for Settings. 
    /// </summary> 
    Settings = public partial class(System.Windows.Forms.Form) 
    private 
     method Settings_Shown(sender: System.Object; e: System.EventArgs); 
     method GetLowerBound : System.Nullable<Double>; 
     method SetLowerBound(lowerbound:System.Nullable<Double>); 
     method Settings_Load(sender: System.Object; e: System.EventArgs); 
     method btnOK_Click(sender: System.Object; e: System.EventArgs); 
    protected 
     method Dispose(aDisposing: Boolean); override; 
    public 
     property LowerBound : System.Nullable<Double> read GetLowerBound write SetLowerBound; 
    constructor; 
    end; 

implementation 

{$REGION Construction and Disposition} 
constructor Settings; 
begin 
    // 
    // Required for Windows Form Designer support 
    // 
    InitializeComponent(); 

    // 
    // TODO: Add any constructor code after InitializeComponent call 
    // 
end; 

method Settings.Dispose(aDisposing: Boolean); 
begin 
    if aDisposing then begin 
    if assigned(components) then 
     components.Dispose(); 

    // 
    // TODO: Add custom disposition code here 
    // 
    end; 
    inherited Dispose(aDisposing); 
end; 
{$ENDREGION} 

method Settings.Settings_Shown(sender: System.Object; e: System.EventArgs); 
begin 
    LowerBound := System.Nullable<Double>(Controller.configuration.LowerBound); 
end; 

method Settings.GetLowerBound : System.Nullable<Double>; 
begin 
    var bound : Double; 
    if Double.TryParse(txtLowerBound.Text, out bound) then 
    begin 
     Result := bound; 
    end else 
    begin 
     Result := System.Nullable<Double>(nil); 
    end; 
end; 

method Settings.SetLowerBound(lowerbound:System.Nullable<Double>); 
begin 
    if lowerbound.HasValue then 
    begin 
     txtLowerBound.Text := lowerbound.Value.ToString; 
    end else 
    begin 
     txtLowerBound.Text := ''; 
    end; 
end; 

method Settings.Settings_Load(sender: System.Object; e: System.EventArgs); 
begin 

end; 

method Settings.btnOK_Click(sender: System.Object; e: System.EventArgs); 
begin 
    var LB : System.Nullable<Double> := Self.GetLowerBound; 

    if LB.HasValue then 
    begin 
     Controller.configuration.LowerBound := LB.Value; 
    end; 
end; 

end. 

내가 버튼을 클릭

에 문제가 발생한 것 같습니다 btnOK_Click 이벤트가 발생했습니다. 이상한 오류 메시지가 나타납니다.

런타임에 치명적인 오류가 발생했습니다. 오류 의 주소는 0x691886da이고 스레드 0x770에있었습니다. 오류 코드는 0xc0000005입니다. 이 오류는 CLR 또는 안전하지 않거나 확인할 수없는 사용자 코드의 버그 일 수 있습니다. 이 버그의 일반적인 소스에는 COM- interop 또는 PInvoke에 대한 사용자 지정 오류 ( 스택 손상 될 수 있음)가 포함됩니다. 이 m의 UCH는 더 투명 작품으로

답변

2

FWIW으로

Result := System.Nullable<Double>(nil); 

를 대체하는 것입니다 생각 System.Nullable보다 직관적으로. 예 :

method Settings.GetLowerBound : nullable Double; 
begin 
    var bound : Double; 
    if Double.TryParse(txtLowerBound.Text, out bound) then 
    begin 
     Result := bound; 
    end else 
    begin 
     Result := nil; 
    end; 
end; 

"런타임에 치명적인 오류가 발생했습니다." 컴파일러 오류를 나타냅니다. 나는 당신의 테스트 케이스와 함께 우리쪽에 문제를 기록 할 것이다.

0

나는, 내가 옥시 젼의 "널 (NULL)"언어 기능 내장을 사용하는 것이 좋습니다 것,이 솔루션은

Result := new System.Nullable<Double>; 
2

이것은 컴파일러 오류로 보입니다. RemObjects에 대한 정보를 파일 버그로 전달하고 수정했습니다. 그 시간에 newer version (또는 아마도 beta)을 시도해보십시오.

+0

은 버그로 우리의 내부 버그 데이터베이스에 로그인 : // 61996 : "런타임에 치명적인 오류가 발생했습니다." nullable 캐스트가있는 경우 –

+0

미래에 버그 리포트를 제출할 수있는 가장 좋은 곳은 어디입니까? – sav

+1

remomjects.com의 이메일 지원 @ –