How to extract attribute data - draft file

Valued Contributor
Valued Contributor

Hi,

   I am extracting the attribute data for the draft files. I found that the hierarcy is like propertysets -> properties -> property etc., I wrote a code which works absolutely fine.but my problem is

// CODE SNIPPET

private void button4_Click(object sender, EventArgs e)

{    

   SolidEdgeFileProperties.PropertySets propertysets = new SolidEdgeFileProperties.PropertySets(); 

   propertysets.Open(FileName,true);

   SolidEdgeFileProperties.Properties properties = null; 

   SolidEdgeFileProperties.Property property = null; 

   for (int i = 0; i

   { 

      properties = (SolidEdgeFileProperties.Properties)propertysets; 

      for (int j = 0; j

      { 

         property = (SolidEdgeFileProperties.Property)properties[j]; 

         try 

         { 

            MessageBox.Show(property.Name.ToString().ToUpper() + " : " + property.Value.ToString().ToUpper()); 

         } 

         catch (Exception ex) 

         { 

         MessageBox.Show(ex.Message.ToString()); 

         } 

      } 

   }

}

 

WHEN I USED THE SAME CODE IN BACKGROUNDWORKER (CONCEPT OF MULTI THREADING) IT IS THROWING

ACCESSVIOLATION EXCEPTION ERROR."ATTEMPTED TO READ OR WRITE PROTECTED MEMORY.THIS IS OFTEN AN INDICATION THAT OTHER MEMORY IS CORRUPTED".

 

Why is this happening..?

Please help me in this regard.Thanks in advance

 

Regards

Venkata Ramesh V

 

Posted by: Venkata Ramesh Virodhula
Post date: 9/19/2011 12:52:09 AM

1 REPLY

RE: How to extract attribute data - draft file

Valued Contributor
Valued Contributor

Ramesh,

 

some time ago i observed exactly the same behaviour and error message when using the SolidEdgeFileProperties object from within a BackgroundWorker process. It is not possible to use the SolidEdgeFileProperties COM object in combination with the .NET BackgroundWorker object. I assume the problem is related to the fact that COM (Interop) works in most cases with threads in Single-Threaded Apartment Mode (STA) only. The BackgroundWorker component doesn't allow to specify the Apartment mode to run in whereas the 'normal' Thread component does.

 

 

Posted by: Wolfgang Kunert
Post date: 9/26/2011 12:34:38 AM