Quantcast
Channel: R.NET
Viewing all articles
Browse latest Browse all 1634

Commented Unassigned: C# App crashes while getting row from dataframe [150]

$
0
0
Hi,
Can anyone help me on this.
I am facing this weird issue, when I try to fetch some rows(row by row) from my dataset(dataframe in R). First few rows are fetched without any error but after say 4-5 rows I get some exception on a line which executed perfectly for first few rows.
I am executing following statement:

SomeRDotNetObject.Evaluate("Dataset1[rowindex , ]" ); // Dataset1 is the name of the dataset

for say rowindex= 1 to 4 this works but fails on rowindex=5. And C# application crashes with following exception:-

_System.Windows.Threading.DispatcherUnhandledExceptionEventHandler -METHOD :Invoke() -LINE :0
System.InvalidOperationException: Dispatcher processing has been suspended, but messages are still being processed.
at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)_


Thanks
adabral
Comments: Loading data to a grid dynamically is a common use case (think of loading data from a large SQL table or a large file). This is commonly done by implementing IBindingList. When you implement IBindingList, you have to write functions for some of the methods namely object IList.this[int index] , which fetches the next row from R dynamically. This is where things break down when we are fetching the next row of the dataset in R. Infact it crashes very quickly. Within the first 10 rows that are fetched into the virtual grid. This happens when using the .net Grid class, I reviewed that code sample in the thread submitted by adabral and that is pretty complex. The problem can be created simply setting the itemsource of a grid to a class that implements iBindinglist and fetch the row from R in the IList.this[int index] method.In this thread there is a mention that this could be occurring as R is writing to the console device, I have created a sample where I get the row using getsymbol instead of evaluating dataset{rowindex,], problem still occurs. The point I want to make is virtual grids and just in time loading are pretty popular in C# apps. In fact, I was hoping to move from statconn (www.statconn.com) to R dot net this weekend, this is the only issue that is preventing me from moving to R dot net. Everything else works like a charm. I was using the DCOM version of statconn and can send you some code to demonstrate that statconn works. Could this mean that this is not an R problem? I have not tried statconn.net yet. But would prefer to work with r dot net because of the licensing. Hoping you can address this. I tried a separate Rengine for fetching each row of the dataset, it did not work, infact it crashed at the same point. Also tried to reproduce with older version of R Dot Net, could not find the binaries. Can you point me to them? Feel that compatibility with iBindinglist should be a popular capability that many developers should be able to take advantage off. Also thread about Dispatcher.CurrentDispatcher.BeginInvoke. This makes sense if I am loading the entire dataset asynchronously. This is not what I am intending. I want users to scroll through the dataset on demand. In my application (with statconn dcom) this works fine. Datasets are sometimes 500MB-1GB. I have modified the code attached that demonstrates the problem quite clearly. The example now has following options: 1) First radio button will create data in C# and the will be assigned to the ItemSource property of the DataGrid. Obviously this case does not fail. There are no calls made to R.net. 2) Second radio button will fetch rows from R, using R.net and create a collection, which is finally assigned to the ItemSource property of the DataGrid. This also works but, is far from ideal, as we are moving entire dataset from R to C# and not loading data dyanamically from R. 3) Third radio button: Here we are loading data from R dynamically into C#.It will assign object of the MyData class that implements IBindingList and IEnumerator, and the DataGrid itself uses indexer from MyData, to fetch rows, dynamically. Here you will see the failure occur when fetching first 12 rows. 4) I created the fourth option, just to isolate, whether the problem occurs only with iterating dataset. So instead of making call like "Dataset1[index,]", I am evaluating a hard coded R command as c('111', '222', '333'). And the problem occurs here also. Basically,this option is same as the third one, except it does not fetch rows from Dataset1, instead it fetches c('111', '222', '333') from R, using R.net

Viewing all articles
Browse latest Browse all 1634

Trending Articles