Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #8823 > unrolled thread
| Started by | Guido <guido.reichert@gmx.de> |
|---|---|
| First post | 2012-03-01 10:43 +0000 |
| Last post | 2012-03-03 11:55 +0000 |
| Articles | 4 — 3 participants |
Back to article view | Back to comp.soft-sys.math.mathematica
Can you call 32 Bit DLLs from Mathematica 8.0 ? Guido <guido.reichert@gmx.de> - 2012-03-01 10:43 +0000
Re: Can you call 32 Bit DLLs from Mathematica 8.0 ? "Oleksandr Rasputinov" <oleksandr_rasputinov@ymail.com> - 2012-03-02 12:48 +0000
Re: Can you call 32 Bit DLLs from Mathematica Todd Gayley <tgayley@wolfram.com> - 2012-03-03 11:57 +0000
Re: Can you call 32 Bit DLLs from Mathematica 8.0 ? Guido <guido.reichert@gmx.de> - 2012-03-03 11:55 +0000
| From | Guido <guido.reichert@gmx.de> |
|---|---|
| Date | 2012-03-01 10:43 +0000 |
| Subject | Can you call 32 Bit DLLs from Mathematica 8.0 ? |
| Message-ID | <jinjsa$d4v$1@smc.vnet.net> |
I am using a System Dynamics software (Vensim DSS) that is still a 32 Bit application and provides a full 32 Bit DLL for use with other programs. I had thought that I can call that DLL from Mathematica 8.0. Such a call produces a 'BadFormat' error and the Vensim support says that 64 Bit and 32 Bit do not mix well. Is there any chance to call a 32 Bit DLL from Mathematica 8.0? Kind regards Guido
[toc] | [next] | [standalone]
| From | "Oleksandr Rasputinov" <oleksandr_rasputinov@ymail.com> |
|---|---|
| Date | 2012-03-02 12:48 +0000 |
| Message-ID | <jiqfjm$2p$1@smc.vnet.net> |
| In reply to | #8823 |
On Thu, 01 Mar 2012 10:43:22 -0000, Guido <guido.reichert@gmx.de> wrote:
> I am using a System Dynamics software (Vensim DSS) that is still a 32
> Bit application and provides a full 32 Bit DLL for use with other
> programs. I had thought that I can call that DLL from Mathematica 8.0.
>
> Such a call produces a 'BadFormat' error and the Vensim support says
> that 64 Bit and 32 Bit do not mix well. Is there any chance to call a
> 32 Bit DLL from Mathematica 8.0?
>
> Kind regards
>
> Guido
>
Not from the 64-bit version, no; it is simply not possible for a 64-bit
Windows process to load a 32-bit DLL directly. Fortunately, both 32- and
64-bit versions of Mathematica are provided in the standard installation,
probably for exactly this reason. To help you start the 32-bit Mathematica
kernel on a 64-bit system, you can evaluate:
SetOptions[$FrontEnd,
EvaluatorNames -> Append[
EvaluatorNames /. Options[$FrontEnd],
"Local (32-bit)" -> {
"AutoStartOnLaunch" -> False,
"Executable" -> FileNameJoin[{
$InstallationDirectory, "SystemFiles",
"Kernel", "Binaries", "Windows", "MathKernel.exe"
}]
}
]
];
which adds an entry for the 32-bit kernel in the kernel configuration
options dialog, i.e. the one produced by evaluating:
FrontEndExecute@FrontEndToken["ModifyEvaluatorNames"]
With this set up, you just need to select the menu option Evaluation |
Notebook's Kernel | Local (32-bit) in a new notebook (before evaluating
anything) in order to have that notebook use the 32-bit kernel. This can
also be accomplished programmatically by evaluating:
SetOptions[EvaluationNotebook[], Evaluator -> "Local (32-bit)"]
Saving the notebook also saves the kernel configuration, so it will still
run on the 32-bit kernel when closed and re-opened.
[toc] | [prev] | [next] | [standalone]
| From | Todd Gayley <tgayley@wolfram.com> |
|---|---|
| Date | 2012-03-03 11:57 +0000 |
| Subject | Re: Can you call 32 Bit DLLs from Mathematica |
| Message-ID | <jit0v4$e74$1@smc.vnet.net> |
| In reply to | #8823 |
At 06:48 AM 3/2/2012, Oleksandr Rasputinov wrote:
>On Thu, 01 Mar 2012 10:43:22 -0000, Guido <guido.reichert@gmx.de> wrote:
>
> > I am using a System Dynamics software (Vensim DSS) that is still a 32
> > Bit application and provides a full 32 Bit DLL for use with other
> > programs. I had thought that I can call that DLL from Mathematica 8.0.
> >
> > Such a call produces a 'BadFormat' error and the Vensim support says
> > that 64 Bit and 32 Bit do not mix well. Is there any chance to call a
> > 32 Bit DLL from Mathematica 8.0?
> >
> > Kind regards
> >
> > Guido
> >
>
>Not from the 64-bit version, no; it is simply not possible for a 64-bit
>Windows process to load a 32-bit DLL directly. Fortunately, both 32- and
>64-bit versions of Mathematica are provided in the standard installation,
>probably for exactly this reason. To help you start the 32-bit Mathematica
>kernel on a 64-bit system, you can evaluate:
>
>SetOptions[$FrontEnd,
> EvaluatorNames -> Append[
> EvaluatorNames /. Options[$FrontEnd],
> "Local (32-bit)" -> {
> "AutoStartOnLaunch" -> False,
> "Executable" -> FileNameJoin[{
> $InstallationDirectory, "SystemFiles",
> "Kernel", "Binaries", "Windows", "MathKernel.exe"
> }]
> }
> ]
>];
>
>which adds an entry for the 32-bit kernel in the kernel configuration
>options dialog, i.e. the one produced by evaluating:
>
>FrontEndExecute@FrontEndToken["ModifyEvaluatorNames"]
>
>With this set up, you just need to select the menu option Evaluation |
>Notebook's Kernel | Local (32-bit) in a new notebook (before evaluating
>anything) in order to have that notebook use the 32-bit kernel. This can
>also be accomplished programmatically by evaluating:
>
>SetOptions[EvaluationNotebook[], Evaluator -> "Local (32-bit)"]
That's a great tip, and I have never seen that described, but I don't
think it will solve the original poster's problem. It's the bitness
of the .NET/Link process, not Mathematica, that needs to match the
DLL he is calling. Even if he runs a 32-bit Mathematica kernel, when
.NET/Link is launched it will be a native 64-bit .NET process because
the operating system is 64-bit Windows.
The way to handle the problem is to force .NET/Link to run in 32-bit mode:
ReinstallNET["Force32Bit" -> True]
Todd Gayley
Wolfram Research
[toc] | [prev] | [next] | [standalone]
| From | Guido <guido.reichert@gmx.de> |
|---|---|
| Date | 2012-03-03 11:55 +0000 |
| Message-ID | <jit0s7$e5t$1@smc.vnet.net> |
| In reply to | #8823 |
On 1 Mrz., 11:43, Guido <guido.reich...@gmx.de> wrote: > I am using a System Dynamics software (Vensim DSS) that is still a 32 > Bit application and provides a full 32 Bit DLL for use with other > programs. I had thought that I can call that DLL from Mathematica 8.0. > > Such a call produces a 'BadFormat' error and the Vensim support says > that 64 Bit and 32 Bit do not mix well. Is there any chance to call a > 32 Bit DLL from Mathematica 8.0? > > Kind regards > > Guido Next to setting the Kernel to be loaded in the 32 Bit version as has been suggested here, there seems to be a more simple method available since what matters should be the .NET/Link application and that can be set to load as 32 Bit which then enables the use of 32 Bit DLLs and precludes the use of 64 Bit ones. For the original reference see here: http://mathematica.stackexchange.com/questions/2519/how-do-i-call-a-32-bit-dll-using-net-link-and-a-64-bit-version-of-mathematica So what needs to be done is: Needs["NetLink`"] UninstallNET[] InstallNET["Force32Bit" -> True] with this everything so far seems to work out. I am not sure whether the UninstallNet[] is necessary as it seems to also work without it. Guido
[toc] | [prev] | [standalone]
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web