Using 64-bit SPSS libraries in C #

I am trying to create a .sav file programmatically without using SPSS automation (SPSS.BackendAPI library) to free up more SPSS licenses. I found this library in CodePlex that uses a 32-bit I / O module without requiring a license, which is good.

The problem is that I need to create an application as x64 in order to access the additional addressable memory in my own application. Thus, I also need to use 64-bit libraries. Is anyone lucky with using 64-bit libraries in managed code?

+4
source share
2 answers

You can use this library from CodePlex, but you will have to modify it a bit to work with spssio64.dll, which is included in the I / O module. In the SpssThinWrapper.cs file SpssThinWrapper.cs you need to modify the imported DLL. You will also have to change some entry points. To get the entry point names in a 64-bit DLL, you need to run dumpbin /exports spssio64.dll . If you do this, you will see that the 64-bit and 32-bit entry points are basically the same, except that some of the 32-bit ones have an @ sign and a number after them, while none of the 64-bit ones. Modify all of these files along with the DLL in the DllImport attribute. For instance:

 [DllImport("spssio32.dll", EntryPoint=" spssCloseAppend@4 ", CharSet=CharSet.Ansi, SetLastError=true, ExactSpelling=true)] public static extern ReturnCode spssCloseAppend(int handle); 

becomes

 [DllImport("spssio64.dll", EntryPoint = "spssCloseAppend", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)] public static extern ReturnCode spssCloseAppend(int handle); 

etc.

After that, you will want to make sure that you are using the correct DLLs. Copy spssio64.dll, icudt32.dll, icuin32.dll and icuuc32.dll from the win64 folder of the I / O module to the Resources folder from the SPSS.NET library from CodePlex. This will overwrite existing 32-bit DLLs, so if you need both 32-bit and 64-bit, you will have to do something else, but it looks like you just need 64-bit, so this should work.

As an example of how easy it is to create .sav with this library:

 using (SpssDataDocument spssDoc = SpssDataDocument.Create("test.sav")) { SpssVariable v = new SpssNumericVariable(); v.Name = "gender"; v.Label = "What is your gender?"; v.ValueLabels.Add(1, "Male"); v.ValueLabels.Add(2, "Female"); doc.Variables.Add(v); doc.CommitDictionary(); SpssCase c = doc.Cases.New(); c["gender"] = 1; c.Commit(); } 

The library handles all spss * calls for you and ensures that they are in the correct order and that’s all.

+5
source

Why don't you just use the SPSS Statistics i / o dll, available through the SPSS community website (www.ibm.com/developerworks/spssdevcentral)? It is free and comes in 32 and 64-bit versions for all supported SPSS platforms. It does not require an SPSS license.

+3
source

Source: https://habr.com/ru/post/1347285/


All Articles