the addin developed for SW2013 doesn't work for SW2014

Hi there,

I once developed an addin for SolidWorks 2013, and it works very well. Recently we installed new version of SolidWorks - SW 2014 SP01 while still keep the 2013 version in case there are incompatible issues. So, the installation folder for SW2013 is c:\\Program files\\SoliWorks Corp\\SolidWorks, and SW 2014 is installed in c:\\Program files\\SoliWorks Corp\\SolidWorks (2).

After this upgrade, my addin developed for SW 2013 doesn't work: it causes SW shut-down frequently... In order to solve the problem, I downloaded the SW2014 API SDK and rebuilt the project by replacing the SW2013 references with the SW2014 references. However, it still keeps generating exceptions like this:

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

it is weird that the exception was thrown out at different points each time when I debugged with the same case.

The addin has a function of retrieving cut list items from model. The exceptions are generated when it executes the following 2 sentences:

vPropNames = (string[])Cutlist.GetCustomPropertyNames();

sValue = Cutlist.GetCustomPropertyValue2(sPropName, out nType, out nLink);

Can anyone please let me know the solution?

Thanks

Tony

SolidworksApi macros
Answers 5
ST
ST 2014-01-03 Best Answer

Which references are you adding?

You should browse to c:\Program files\SoliWorks Corp\SolidWorks (2)\api\redist

Now, if your addin is just going to be used in 2014, then you need to change the target .net framework to 4.0 and use the Interop files in the redist folder.

If you want to use your addin in both 2013 and 2014, then keep the target framework as 3.5 (or 2.0 or 3.0) and use the interop files in redist\CLR2

SF
SF 2014-01-03

Hi Simon,

Thanks for your reply. Here are the references I used. These references locate in c:\program files\Solidworks Corp\SolidWorks (2), and I do find the same references in c:\Program files\SoliWorks Corp\SolidWorks (2)\api\redist except solidworkstools.dll.

I will try to reload the dll in ..\api\redist to see if it works. BTW, can you please let me know the difference of these dll in two different locations?

Thanks

Tony

comment imagecomment image
ST
ST 2014-01-03

The ones in Redist are for .Net 4.0

The ones in CLR2 are for .Net 2.0, 3.0 and 3.5

If you didn't change the targetted .net platform for your addin, then the ones in redist will not work. You must use the ones in CLR2 or change your .Net target to 4.0

SF
SF 2014-01-03

Hi Simon,

It doesn't work either... same exception pops up.

I replaced the dlls with those located in c:\Program files\SoliWorks Corp\SolidWorks (2)\api\redist, and the target framework is .NET FRAMEWORK 4.

BTW, my previous question is: I found the same dlls in c:\Program files\SoliWorks Corp\SolidWorks (2). So there are 3 types of dlls located in c:\Program files\SoliWorks Corp\SolidWorks (2), c:\Program files\SoliWorks Corp\SolidWorks (2)\api\redist, and c:\Program files\SoliWorks Corp\SolidWorks (2)\api\redist\CLR2. You explained the difference between the latter 2. But how about the dlls located in the first folder?

Thanks

Tony

SF
SF 2014-01-03

I reorgainzed the data structure and rewrote the codes as well. Now the problem is solved.

Thanks for your help and attention, anyway.

Tony