Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 588657
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T15:20:29+00:00 2026-05-13T15:20:29+00:00

I have been writing a small application using C# to copy a document into

  • 0

I have been writing a small application using C# to copy a document into an individuals ‘My Documents’ folder on our DMS server.

I’ve beased the code around the listing provided in the ‘WorkSite SDK 8: Utilize the IMANEXT2Lib.IManRefileCmd to File New Document Folders’ blog.

Using this code in a WinForm application I have no problems copying the file from the source folder into the users DMS ‘My Documents’ folder.

However if I use the code in a command line application/.dll or any other type of application (other than WinForm) during the copy process I receive the error messages;

1.

Error occurred when try to log the event!

IManExt: Error occurred when try to log the event!

Access is denied.

2.

The document was imported to the database, but could not be added to
the folder.

IManExt: The document was imported to the database, but could not be
added to the folder.

IManExt.LogRuleEventsCmd.1: Error occurred when try to log the event!

IManExt.LogRuleEventsCmd.1: Access is denied.

Error occurred when try to log the event!

-%-

Does anyone know why I’d receiving the ‘Access Denied’ error messages when using a non-WinForms application to copy documents?
What would I need to do to get around this issue?

Any help would be amazing!

Code in place:

    public void moveToDMS(String servName, String dBName, String foldName)
    {
        const string SERVERNAME = servName; //Server name
        const string DATABASENAME = dBName; //Database name
        const string FOLDERNAME = foldName; //Matter alias of workspace

        IManDMS dms = new ManDMSClass();
        IManSession sess = dms.Sessions.Add(SERVERNAME);
        sess.TrustedLogin();

        //Get destination database.
        IManDatabase db = sess.Databases.ItemByName(DATABASENAME);

        //Get destination folder by folder and owner name.
        IManFolderSearchParameters fparms = dms.CreateFolderSearchParameters();
        fparms.Add(imFolderAttributeID.imFolderOwner, sess.UserID);
        fparms.Add(imFolderAttributeID.imFolderName, FOLDERNAME);           

        //Build a database list in which to search.
        ManStrings dblist = new ManStringsClass();
        dblist.Add(db.Name);

        IManFolders results = sess.WorkArea.SearchFolders(dblist, fparms);

        if (results.Empty == true)
        {
            //No results returned based on the search criteria.
            Console.WriteLine("NO RESULTS FOUND!");
        }

        IManDocumentFolder fldr = null;

        if (results.Empty == false)
        {
            //Assuming there is only one workspace returned from the results.
            fldr = (IManDocumentFolder)results.ItemByIndex(1);
        }

        if (fldr != null)
        {
            // Import file path
            string docPath = @"C:\Temp\";
            string docName = "MyWord.doc";

            // Create an instance of the ContextItems Collection Object.
            ContextItems context = new ContextItemsClass();

            // Invoke ImportCmd to import a new document to WorkSite database.
            ImportCmd impCmd = new ImportCmdClass();

            // The WorkSite object you pass in can be a database, session, or folder.
            // Depends on in where you want the imported doc to be stored.
            context.Add("IManDestinationObject", fldr); //The destination folder.

            // Filename set here is used for easy example, a string variable is normally used here
            context.Add("IManExt.Import.FileName", docPath + docName);

            // Document Author
            context.Add("IManExt.Import.DocAuthor", sess.UserID); //Example of a application type.

            // Document Class
            context.Add("IManExt.Import.DocClass", "BLANK"); //Example of a document class.
            //context.Add("IManExt.Import.DocClass", "DOC"); //Example of a document class.

            // Document Description (optional)
            context.Add("IManExt.Import.DocDescription", docName); //Using file path as example of a description.

            // Skip UI
            context.Add("IManExt.NewProfile.ProfileNoUI", true);

            impCmd.Initialize(context);
            impCmd.Update();

            if (impCmd.Status == (int)CommandStatus.nrActiveCommand)
            {
                impCmd.Execute();

                bool brefresh = (bool)context.Item("IManExt.Refresh");
                if (brefresh == true)
                {
                    //Succeeded in importing a document to WorkSite
                    IManDocument doc = (IManDocument)context.Item("ImportedDocument");

                    //Succeeded in filing the new folder under the folder.
                    Console.WriteLine("New document number, " + doc.Number + ", is successfully filed to " + fldr.Name + " folder.");
                }

            }


        }

    }

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T15:20:30+00:00Added an answer on May 13, 2026 at 3:20 pm

    Just in case this helps someone else.

    It seems my issue was the result of a threading issue.

    I noticed the C# winform apps I had created were automatically set to run on a single ‘ApartmentState‘ thread ([STAThread]).

    Whereas the console applications & class library thread state and management hadn’t been defined within the project and was being handled with the default .NET config.

    To get this to work: In the console application, I just added the [STAThread] tag on the line above my Main method call.

    In the class library, I defined a thread for the function referencing the IMANxxx.dll and set ApartmentState e.g.

    Thread t = new Thread(new ThreadStart(PerformSearchAndMove));
    t.SetApartmentState(ApartmentState.STA);
    t.Start();
    

    In both cases ensuring single ‘ApartmentState‘ thread was implemented set would resolve the issue.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 357k
  • Answers 357k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You probably want to call setlocale() first, "LC_ALL" should do… May 14, 2026 at 9:06 am
  • Editorial Team
    Editorial Team added an answer Linux Ubuntu Desktop Jaunty Firebug FireCookie Pixel Perfect Web developer… May 14, 2026 at 9:06 am
  • Editorial Team
    Editorial Team added an answer Your code should look like this: var par = [];… May 14, 2026 at 9:06 am

Related Questions

I've been experimenting with the 32Feet library, which enables support for using IrDA using
I found a blog entry which suggests that sometimes c# compiler may decide to
I'm working on a video codec for OMAP3430. I already have code written in
I'm a .NET web developer who has just been asked to produce a small
Just before I begin heres a small overview of what I'm trying to achieve

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.