Strange CLR error while handling Nullable types in Oxygene .net -


i'm writing program in oxygene .net there seems problem how handling nullable types

    namespace ruler;  interface  uses   system,   system.drawing,   system.collections,   system.collections.generic,   system.windows.forms,   system.componentmodel;  type   /// <summary>   /// summary description 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 , disposition} constructor settings; begin   //   // required windows form designer support   //   initializecomponent();    //   // todo: add constructor code after initializecomponent call   // end;  method settings.dispose(adisposing: boolean); begin   if adisposing begin     if assigned(components)       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)     begin         result := bound;     end else     begin         result := system.nullable<double>(nil);     end; end;  method settings.setlowerbound(lowerbound:system.nullable<double>); begin     if lowerbound.hasvalue     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     begin         controller.configuration.lowerbound := lb.value;     end; end;  end. 

when click button firing btnok_click event strange error message

the runtime has encountered fatal error. address of error @ 0x691886da, on thread 0x770. error code 0xc0000005. error may bug in clr or in unsafe or non-verifiable portions of user code. common sources of bug include user marshaling errors com-interop or pinvoke, may corrupt stack.

fwiw, suggest using oxygene's built in "nullable" language feature, works m uch more transparent , intuitively system.nullable. e.g:

method settings.getlowerbound : nullable double; begin     var bound : double;     if double.tryparse(txtlowerbound.text, out bound)     begin         result := bound;     end else     begin         result := nil;     end; end; 

regardless, getting "the runtime has encountered fatal error." indicative of compiler error. log issue on our side testcase.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -