delphi - SharePoint ClientContext.ExecuteQuery works in c# application but crashes in DLL -


i have written c# code search specific file types in sharepoint lists within site , display file names in listview. code works in c# windows application, when compiled c# dll , called delphi2007 application crashes when hits first call clientcontext.executequery(). there no exception or error message - delphi application stops running.

the weird part delphi test application has web browser component, , if use navigate top level list on site dll works ok.

the question therefore why first executequery call fail in dll if haven't logged on site first?

this c# code:

        public void listfiles()         {             string lcontains = "<contains><fieldref name='fileleafref'/>   <value type ='text'>{0}</value></contains>";             string lnotequal = "<contains><fieldref name='fileleafref'/><value type ='text'>{0}</value></contains>";             string lwherequery = "";              switch (combofiletype.selectedindex)             {                 case 0: lwherequery = string.format(lcontains, ".doc"); break;                 case 1: lwherequery = string.format(lcontains, ".pdf"); break;                 case 2: lwherequery = string.format(lnotequal, "xxxx"); break;             }               uri luri = new uri(sharepointurl);             using (sp.clientcontext lcontext = new sp.clientcontext(sharepointurl))             {                 system.net.credentialcache cc = new system.net.credentialcache();                  if (!string.isnullorempty(domain))                     cc.add(luri, authenticationtype, new system.net.networkcredential(username, password, domain));                 else                     cc.add(luri, authenticationtype, new system.net.networkcredential(username, password));                  lcontext.credentials = cc;                 lcontext.authenticationmode = sp.clientauthenticationmode.default;                  var lweb = lcontext.web;                 lvitems.beginupdate();                 try                 {                     try                     {                         sp.list llist = lweb.lists.getbytitle(defaultlistname);                          sp.camlquery lquery = new sp.camlquery();                         lquery.viewxml = "<view scope='recursiveall'><query><where>"                             + lwherequery                             + "</where></query><rowlimit> 30 </rowlimit></view>";                          sp.listitemcollection litems = llist.getitems(lquery);                          lcontext.load(litems);                         lcontext.executequery();  **<<<< crash happens here**                              foreach (sp.listitem litem in litems)                             {                                 sp.file lfile = litem.file;                                 lcontext.load(lfile);                                 lcontext.executequery();                                  var lviewitem = new listviewitem();                                  try { lviewitem.text = lfile.name; }                                 catch { lviewitem.text = "!error"; }                                  try { lviewitem.subitems.add(lfile.timelastmodified.tostring()); }                                 catch { lviewitem.subitems.add("!error"); }                                  if (lfile.checkouttype != microsoft.sharepoint.client.checkouttype.none)                                 {                                     try { lviewitem.subitems.add(lfile.checkedoutbyuser.loginname); }                                     catch { lviewitem.subitems.add("!error"); }                                 }                                 else                                     lviewitem.subitems.add("not checked out.");                                  try { lviewitem.tag = lfile.serverrelativeurl; }                                 catch { lviewitem.tag = "!error"; }                                  lvitems.items.add(lviewitem);                              }                         }                     }                     catch (exception ex)                     {                         messagebox.show("error: " + ex);                     }                 }                                 {                     lvitems.endupdate();                 }          } 

the code in .cs of dialog form in dll. form displays should , crash happens when click button search.

i put debug code in check string params etc. (by writing them text file) , ok.

i tried debugging dll vs specifying d2007 app 'startup external program' can't breakpoints work , @ point crashes says: an unhandled exception of type 'system.stackoverflowexception' occurred in microsoft.sharepoint.client.runtime.dll , suggests might have infinite recursive call but, mentioned earlier, code works if have logged site , browsed top level list, don't think recursive call.

update: got debugging work copying delphi exe same directory dll.

i've tried using exceptionhandlingscope hasn't helped. how looks when crashes:

stackoverflow error in mssp client runtime dll

the scope has no exception , errormessage blank. tried few connotations of inside scope no avail.

the whole code block in try..catch , i've tried wrapping executequery line in it's own try..catch well, nothing catches it. app crashes out every time when hit continue.

i've tried putting execute query before loading web still crashes out.

i'm thinking has credentials? if deliberately put wrong username polite '401 unauthorized' , no crash. , if i'm logged in doesn't crash either?

after trying c# test application tried same delphi xe8 , worked, in end i've resorted writing intermediate dll in xe8.

i noticed when importing tlb c# dll xe8 behaved differently d2007 in complained other missing tlb's when building - notably system.windows.forms library (and dependencies). i'm not sure if has bearing on xe8 working , d2007 failing, else needing workaround.


Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -