Topic
  • No replies
SystemAdmin
SystemAdmin
6968 Posts

Pinned topic Problem with isyncore

‏2009-04-21T15:03:49Z |
I'm trying to implement the following clientapisample that came with DB2Everywhere Enterprise trial. When I try to start the application, Visual Studio says the following: "System.DllNotFoundException: Unable to load DLL 'isyncore'". From what I understand isyncore.dll needs to be placed somewhere for the program to function correctly. My question: where do I need to place this dll?

Thx in advance.

This is the sample code:



/************************************************************************ * * Licensed Materials - Property of IBM * Program Name: IBM DB2Everyplace Sync Client GUI * (c ) Copyright IBM Corp. 1999-2003. All Rights Reserved. * * US Government Users Restricted Rights * Use, duplication or disclosure restricted by GSA ADP Schedule * Contract with IBM Corp. Licensed Materials - Property of IBM * * IBM grants you ("Licensee") a non-exclusive, royalty free, license to * use Sample Code.  This software is provided as-is and without any * warranties, whether EXPRESS OR  IMPLIED, INCLUDING ANY IMPLIED * WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR * NON-INFRINGEMENT. IBM AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY * DAMAGES SUFFERED BY LICENSEE THAT RESULT FROM YOUR USE OF THE SOFTWARE. * IN NO EVENT WILL IBM OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, * PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, * INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE * THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE * SOFTWARE, EVEN IF IBM HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH * DAMAGES. * ************************************************************************ */   using System; using System.Text; using System.Collections;   
// Step 1:  using IBM Sync Client namespace 
//  using IBM.Data.Sync;   #

if (!UNDER_CF) using IBM.Data.Sync.DB2e;             
//standard framework #

else using IBM.Data.Sync.DB2e.CF; 
//compact framework #endif   
/// <summary> 
/// Example 1:  ISync.NET - Simple API usage. 
/// </summary> 

public 

class ISyncSample 
{ 

private Hashtable userProps = 

new Hashtable();   

public ISyncSample() 
{
}   
// Step 2:  Implement an event handler for ISyncEvent 
//          if you are interested in event notification (optional) 
//  

public 

int EventIssued(Object sender, ISyncEvent evt) 
{ 

int evtType = evt.GetEventType(); 

int evtCode = evt.GetEventCode(); 

switch(evtType) 
{ 

case ISync.EVTTYPE_INFO: 

case ISync.EVTTYPE_ERROR: Console.WriteLine (
"*********************"); Console.WriteLine (
"SubsSet:    " + evt.GetSubscriptionSetName() ); Console.WriteLine (
"Subs:       " + evt.GetSubscriptionName() ); Console.WriteLine (
"SubsType:   " + evt.GetSubscriptionType() ); Console.WriteLine (
"Event Type: " + evtType ); Console.WriteLine (
"Event Code: " + evt.GetEventCode() ); Console.WriteLine (
"Progress:   " + evt.GetSyncProgress()); Console.WriteLine (
"**********************"); 

return ISync.RTNCB_DONE; 

case ISync.EVTTYPE_RETRY: Console.WriteLine (
"*********************"); Console.WriteLine (
"Network connection failed. Retry?"); Console.WriteLine (
"*********************"); 

return ISync.RTNCB_REPLY_NO; 

case ISync.EVTTYPE_CONFLICT: Console.WriteLine (
"*********************"); Console.WriteLine (
"Conflict detected!"); Console.WriteLine (
"*********************"); 

return ISync.RTNCB_DONE;   

case ISync.EVTTYPE_QUERY: 

if (evtCode == ISync.EVT_QUE_LOGIN) 
{ String [] login = (String [])evt.GetEventInfo(); Console.WriteLine(
"Querying login for local encryption."); Console.WriteLine(
"Target: " + login[0]); 
//example login[1] = 
"nurse1"; login[2] = 
"nurse1"; 

return ISync.RTNCB_DONE; 
} 

else 

if (evtCode == ISync.EVT_QUE_SUBSCRIPTION_TARGET) 
{ 

int subsType = evt.GetSubscriptionType(); String []targetDir = (String [])evt.GetEventInfo();   

if (subsType == ISync.SUBSTYPE_FILE) targetDir[0] = 
"filesubdir"; 

else targetDir[0] = 
"database=jdbcsubdir"; Console.WriteLine(
"Sample set subs " + targetDir[0]); 

return ISync.RTNCB_DONE; 
} 

else 

return ISync.RTNCB_DEFAULT;   

default: 

break; 
} 

return ISync.RTNCB_DEFAULT ; 
} 
//end eventIssued   

public 

void RunSample(String host, String port, String userID, String passwrd) 
{ ISyncProvider provider = 

null; ISyncService  service  = 

null; ISyncConfigStore config = 

null; ISyncDriver syncer = 

null; String path = 
"data";         
// a data directory under current dir ISyncSubscriptionSet [] ssArr = 

null; 

int rc = 0; 

try 
{ 
// Step 3:  Get an instance DB2eISyncProvider  
// provider = DB2eISyncProvider.GetInstance();   
// Step 4:  Get an instance of synchronization service from the provider 
// deprecated 
//service = provider.CreateSyncService(host, port, userID, passwrd);   userProps.Add(
"isync.user", userID); userProps.Add(
"isync.password", passwrd);   
// Set a timeout period (in seconds) for synchronization (optional) userProps.Add(
"isync.timeout", 
"120"); String uri = 
"http://" + host; 

if (port != 

null) uri += 
":" + port;   service = provider.CreateSyncService(uri, userProps);   
// Step 5:  Get an instance of the configuration store 
//  config = service.GetConfigStore(path);   
// Step 6:  Get an instance of the sync driver to perform synchronization 
//  syncer = config.GetSyncDriver(); Console.WriteLine(
"About: " + syncer.ToString());   
// Associate the event from ISyncDriver with an user defined event handler 
// (optional) syncer.SyncEvent += 

new ISyncEventHandler(EventIssued);   
// Step 7:  Perform synchronization on all enabled subscription sets 
// rc = syncer.Sync(); 

switch (rc) 
{ 

case ISync.RTN_SUCCEEDED: Console.WriteLine(
"Synchronization succeeded"); 

break; 

case ISync.RTN_CANCELED: Console.WriteLine(
"Synchronization canceled"); 

break; 

default: Console.WriteLine(
"Synchronization failed"); 

break; 
}   ssArr = config.GetSubscriptionSets();   

for (

int i=0; i < ssArr.Length; i++ ) 
{   Console.Write(
"Subscription Set: " + ssArr[i].GetName() + 
" Status: ");   

switch(ssArr[i].GetStatus()) 
{ 

case ISync.STATUS_READY: Console.WriteLine(
"READY"); 

break; 

case ISync.STATUS_COMPLETED: Console.WriteLine(
"COMPLETED"); 

break; 

case ISync.STATUS_CANCELED: Console.WriteLine(
"CANCELED"); 

break;   

default: Console.WriteLine(
"FAILED"); 

break; 
} 
} 
} 

catch (ISyncException ie) 
{ Console.WriteLine(
"Exception code: " + ie.GetCode()); Console.WriteLine(
"Exception message: " + ie.ToString()); 
} 

catch (Exception e) 
{ Console.WriteLine(e.ToString()); 
} 

finally 
{ 

try 
{ 
// Step 8:  Close and free allocated resources by the syncer object 
// 

if (syncer != 

null) 
{ syncer.Close(); syncer = 

null; 
}   
// Step 9:  Close and free allocated resources by the config object 
// 

if (config != 

null) 
{ config.Close(); config = 

null; 
}   
// Step 10:  Close and free allocated resources by the service object 
// 

if (service != 

null) 
{ service.Close(); service = 

null; 
}   
} 

catch(ISyncException ie2) 
{ Console.WriteLine(
"Exception code: " + ie2.GetCode()); Console.WriteLine(
"Exception message: " + ie2.ToString()); 
} 
} 
}  
// end runSample()   

static 

void Main(string[] args) 
{ String host     = 
"localhost"; String port     = 
"8080"; String userID   = 
"nurse1"; String passwrd  = 
"nurse1"; ISyncSample test = 

new ISyncSample();   

if (args.Length > 0) 
{ 

if (args.Length == 4) 
{ host     = args[0]; port     = args[1]; userID   = args[2]; passwrd  = args[3]; 
} 

else Console.WriteLine(
"Usage: ISyncSample [host] [port] [userid] [password]"); 
}   test.RunSample(host, port, userID, passwrd); Console.ReadLine(); 
}   
} 
//end class