// This is C#//// dms is a valid IManDMS object// sess is a valid IManSession object, and it is successfully logged in// aFolder is a valid IManDocumentFolder object// sourceFileName is a valid string holding the full path name of a Word doc// docClass is a string holding a valid document class alias//ContextItems context = new ContextItems();context.Add("IManDMS", dms);context.Add("ParentWindow", 0);context.Add("IManExt.Import.FileName", sourceFileName);context.Add("IManDestinationObject", aFolder);context.Add("IManExt.Import.DocDescription", "ImportCmd Test Doc / " + DateTime.Now.ToString());context.Add("IManExt.Import.DocAuthor", sess.UserID);context.Add("IManExt.Import.DocClass", docClass);context.Add("IManExt.Import.DocType", "WORD");context.Add("IManExt.Import.KeepCheckedOut", imCheckinOptions.imDontKeepCheckedOut);//context.Add("IManExt.OpenCmd.NoCmdUI", true);//context.Add("IManExt.NewProfile.ProfileNoUI", true);//context.Add("IManExt.Import.InheritSecurity", true);ImportCmd cmd = new ImportCmd();cmd.Initialize(context);cmd.Update();if ((CommandStatus) cmd.Status == CommandStatus.nrActiveCommand) { try { cmd.Execute(); } catch (Exception ex) { Console.Error.WriteLine("Err: Execute(): {0}", ex.Message); } IManDocument newDoc = null; try { newDoc = (IManDocument) context.Item("ImportedDocument"); Console.WriteLine("new: {0}_{1}", newDoc.Number, newDoc.Version); } catch (Exception ex) { Console.Error.WriteLine("Err: After Execute(): {0}", ex.Message); }}
Wolfgang:
could it be that the difference in your example is that you are not using the actual class, but creating instead an instance of the imported interface?
When you import a Win32 type library (such as IManExtLIB) into .NET, cocreateable classes such as ImportCmd and ContextItems will ultimately generate a "Class" and an "Interface" pairing.
So, "ImportCmd" is actually the interface definition, whereas "ImportCmdClass" is the implementation of the "ImportCmd" interface.
In other words you might want to try
ContextItems contexts = new ContextItemsClass();
[font=Verdana][size=2][color=#000000]and
ImportCmd cmd = new ImportCmdClass();
[font=Verdana][size=2][color=#000000][font=Verdana][size=2][color=#000000]instead of
ContextItems contexts = new ContextItems();
[font=Verdana][size=2][color=#000000][font=Verdana][size=2][color=#000000]and
ImportCmd cmd = new ImportCmd();
[font=Verdana][size=2][color=#000000][font=Verdana][size=2][color=#000000][font=Verdana][size=2][color=#000000]
just a wild guess!
My understanding is that you should always use the *Class definition when instantiating a new instance of an object.
If you don't you may receive unexpected results when you're trying pass one object to another, as the .NET sees these as 2 different objects (with different GUIDs)
Again, just a guess!
If you don't have a visible window you should set the ParentWindow to a 32bit integer representing the handle of the application executing your code
I am having the same issue.Like a previous poster I am executing the ImportCmd using the .NET backgroundworker. The doc is imported and attached to the target folder, but i get the message boxes popping up about failure to log and access denied.Was this issue resolved ( when running under a background worker ?)
This is a problem caused by .NET as only .NET supplies this type of background worker thread. The source code does not have implemenation to check or support this type of background process. It is currently logged as a bug so that R&D can examine it closely.