Error Msg:



I am trying to update the Custom properties of the part file. I am doing the following.

1  Dim objPropertySets As SolidEdgeFileProperties.PropertySets

2  Dim objProperties As SolidEdgeFileProperties.Properties

3  Dim objProperty As SolidEdgeFileProperties.Property

4  Dim strValue As String = "Test"

5  objPropertySets = New SolidEdgeFileProperties.PropertySets

6  ' Open the file for modification

7  Call objPropertySets.Open(FilePath, False)

8  ' Open the 'Custom' property sets

9  objProperties = objPropertySets.Item("Custom")

10  ' Get a particular property

11  objProperty = objProperties.Item("xxxxx")

12  ' Assign a new value

13  objProperty.Value = strValue

14  ' Save changes           

15  objPropertySets.Save()

16  ' Close property sets

17  objPropertySets.Close()

But doing this, i am getting the following error after line 7.

"Attempted to read or write protected memory. This is often an indication that other memory is corrupt"

I have checked all the issues regarding Permission rights as i thought it might be having problems in reading the file from "FilePath"

Any idea?



Posted by: Prasad Pawar
Post date: 8/12/2008 8:21:14 PM


RE: Error Msg:



What version of Solid Edge and service pack are you using? I've seen this problem before and I'm thinking it was related to a specific version and fixed later. I could be wrong though. I'll do some testing with my V20.


Posted by: Jason Newell
Post date: 8/12/2008 8:26:10 PM

RE: Error Msg:



I am using SE v20 and SP 6




Posted by: Prasad Pawar
Post date: 8/12/2008 8:29:46 PM

RE: Error Msg:



I'm using Solid Edge V20 with no service pack at the moment (  I'm also running Windows XP 64 and I've noticed that I've got to setup special settings to get the code to compile when using the SolidEdgeFileProperties API.  I think that it's related to XP64 though.

I'm not sure if the attached example will work for you or if it's really any different than what you had but you may try it.  I'll have to download SP6 and try it later (after I get some sleep).


Posted by: Jason Newell
Post date: 8/12/2008 8:44:45 PM

RE: Error Msg:

Thanks jason , i will have a look at it.


Posted by: Prasad Pawar
Post date: 8/12/2008 8:50:20 PM

RE: Error Msg:


I ran into a similar problem with SolidEdgeFileProperties. In my case it was because I was using it in a multi-threaded app.

I believe it can only be used in a single threaded app.


Posted by: Rony G
Post date: 8/13/2008 8:27:14 AM

RE: Error Msg:

It's exactly the problem Rony is talking about. You have to set the application to single threaded support. In .Net set the Threading.ApartmantState to STAThread. This will work for the SEFileProperties API.




Posted by: Seb Sosna
Post date: 8/13/2008 9:31:56 PM

RE: Error Msg:

I had this problem as well using C#.


As I recall, your application can in fact be multi-threaded, but the thread that calls the SEFileProperties api must be an STAThread. Typically, your main app thread will be declared as [STAThread], but if you use a thread from the thread pool it will be MTA.


In my app I need to extract some properties from a file in an MTA thread, so I create a new STA thread as below and wait for it to finish:


Thread comThread = new Thread( ExtractProperties );

comThread.Name = "SolidEdgeProps";

comThread.SetApartmentState( ApartmentState.STA );

comThread.Start( fileInfo );



with a method 'private void ExtractProperties( object inArg )' which does the work.


I suppose there's a performance cost in creating a new thread, but it doesn't seem to be too bad.



Andy Sherlock




Posted by: Andrew Sherlock
Post date: 8/14/2008 5:34:38 AM