Forum Discussion

Only1masterbla1's avatar
Mar 31, 2012

ConfigSync::download_configuration() error - Invalid Argument




I'm trying to write C code for ucs file download, but getting runtime error ConfigSync::download_configuration() error - Invalid Argument. Can you please help in fixing my code.



Of course, code is based on blatant copy of the follwing link:



Error Message:



System.Exception was unhandled Message=Not Initialized Source=iControl StackTrace: at iControl.Interfaces.verifyInitialized() in D:\src\perforce\DevCentral\DC4\Labs\iControlAssembly\dotnet\iControl\Interfaces.cs:line 327 at iControl.Interfaces.get_SystemConfigSync() in D:\src\perforce\DevCentral\DC4\Labs\iControlAssembly\dotnet\iControl\Interfaces.cs:line 274 at[] args) in D:\Documents and Settings\kumark\Local Settings\Application Data\Temporary Projects\ConsoleApplication1\Download_UCS1.cs:line 21 at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart() InnerException:



s/w code:




BIG-IP Version 10.2.1 473.0 Hotfix HF1 Edition







My Sample Code:




using System; using System.IO; using System.Collections.Generic; using System.Linq; using System.Text; // using iControl; using System.Web.Services; namespace UCS1 { class download { static void Main(string[] args) { Interfaces m_interfaces = new Interfaces(); // m_interfaces.initialize("", "Guest", "Read"); m_interfaces.initialize("", "Me", "write"); m_interfaces.SystemConfigSync.save_configuration("Test-LB01-20120322", SystemConfigSyncSaveMode.SAVE_FULL); SystemConfigSyncConfigFileEntry[] config_list = m_interfaces.SystemConfigSync.get_configuration_list(); Console.WriteLine("UCS Config Files"); for (int i = 0; i < config_list.Length; i++) { Console.WriteLine(" [" + i + "] : " + config_list.file_name + " " + config_list.file_datetime); } string local_fileName = "C:\\Temp.ucs"; string ucs_fileName = "/var/local/ucs/Test-LB01-20120322.ucs"; if (File.Exists(local_fileName)) { Console.WriteLine(local_fileName + " already exists!"); return; } FileStream fs = new FileStream(local_fileName, FileMode.CreateNew); // Create the writer for data. BinaryWriter w = new BinaryWriter(fs); long chunk_size = (64 * 1024); long file_offset = 0; SystemConfigSyncFileTransferContext download_ctx; bool bContinue = true; while (bContinue) { download_ctx = m_interfaces.SystemConfigSync.download_configuration(ucs_fileName, chunk_size, ref file_offset); w.Write(download_ctx.file_data, 0, download_ctx.file_data.Length); Console.WriteLine("Bytes Transferred: " + file_offset); if ((CommonFileChainType.FILE_LAST == download_ctx.chain_type) || (CommonFileChainType.FILE_FIRST_AND_LAST == download_ctx.chain_type)) { bContinue = false; } } w.Close(); fs.Close(); Console.ReadLine(); } } }

2 Replies

  • Works OK if


    string ucs_fileName = "Test-LB01-20120322.ucs";


    But does not, if full path name is specified...


    string ucs_fileName = "/var/local/ucs/Test-LB01-20120322.ucs";


  • Thanks for confirming the fix. I think that's expected:







    config_name - The name of the configuration file to be retrieved from the device. Length limit: 255. The configuration name should not include any path information, since it will be retrieved automatically from a designated directory.