Cancel
Showing results for 
Search instead for 
Did you mean: 

Reading File Properties using SolidEdgeFileProperties API

Experimenter
Experimenter

I was having trouble with the SolidEdgeFileProperties API.  Trying to get a better understanding, I looked up examples.  I used the examples in the .NET programmer's guide, page 156.  The Visual Basic.NET example works perfectly, however the C# example gives me an error on the line "propertySets.Open(@"C:\Part1.par", true);"

The error is "AccessViolationException" with a description "Attempt to read or write protected memory."  I've tried placing the part in multiple locations on my C drive.  I get the same error on a machin with ST7 and a machine with ST8.  Could someone try to replicate this issue?  Should I put in an Incident report?

10 REPLIES

Re: Reading File Properties using SolidEdgeFileProperties API

Gears Phenom Gears Phenom
Gears Phenom

The problem does not appear to be the file location.

Is the file you are reading open in Solid Edge ?

If so, close it and try the program again.

 

Hope this helps.

 

~Tushar

 

Re: Reading File Properties using SolidEdgeFileProperties API

Experimenter
Experimenter

My issue persists with or without Solid Edge running, the part is not open.

Re: Reading File Properties using SolidEdgeFileProperties API

Gears Phenom Gears Phenom
Gears Phenom

Try making changes as shown in bold below:

 

using System.Runtime.ExceptionServices;
using System.Security;

 

[HandleProcessCorruptedStateExceptions]
[SecurityCritical]
private void button1_Click(object sender, EventArgs e)
{

 

 

Re: Reading File Properties using SolidEdgeFileProperties API

Solution Partner Phenom Solution Partner Phenom
Solution Partner Phenom

@mdsl wrote:

... "propertySets.Open(@"C:\Part1.par", true);"


...

 

Don't you have to double the backslashes in C#?

propertySets.Open(@"C:\\Part1.par", true);

Re: Reading File Properties using SolidEdgeFileProperties API

Experimenter
Experimenter

The "@" symbol tells the compiler to take the raw string verbatim, no escape sequences other than double-double quotes. 

Re: Reading File Properties using SolidEdgeFileProperties API

Experimenter
Experimenter
These additions changed the handling of the exception, but the exception remains the same.

Re: Reading File Properties using SolidEdgeFileProperties API

Solution Partner Phenom Solution Partner Phenom
Solution Partner Phenom

ZIP up the source (or a demo) and reply with an attachment. Too much guessing going on without it. I'd be happy to take a look.

Jason Newell
Applications Architect
www.jasonnewell.net

Re: Reading File Properties using SolidEdgeFileProperties API

Solution Partner Legend Solution Partner Legend
Solution Partner Legend

Hi,

 

can you check your code is running in Single Thread Apartment mode STA?

 

[STAThread] 
static void Main(string[] args)
 { ....

Kind regards,
Wolfgang Kunert - www.wksyspro.de

Re: Reading File Properties using SolidEdgeFileProperties API

Solution Partner Legend Solution Partner Legend
Solution Partner Legend

Hi,

 

can you check your code is running in Single Thread Apartment mode STA?

 

[STAThread] 
static void Main(string[] args)
{
....
}
Kind regards,
Wolfgang Kunert - www.wksyspro.de