R
rmiller407
I am getting an AccessViolationException when calling an old legacy
fortran dll from c# in vs2008 express, but the same code worked fine
in vs2005.
If I create a vs2005 c# wrapper dll to call the old fortran dll, then
I get the exception if I call that wrapper dll from a vs2008 console
app, but not if I call it from a vs2005 console app. I've tried
changing the vs2008 code to target the 2.0 framework, but I still get
the exception. This is all done on the same machine.
I'm running Xpsp2, so I don't think it's the data execution prevention
issue. I tried using editbin to change the nxcomp bit in console app
exe anyway, but it didn't make any difference. I also tried
explicitly excluding that console app exe from the dep through the
control panel, and that didn't make any difference either.
I can call a couple of simple utility methods on the dll without
getting the exception, but when I call the main processing method then
it happens. The dll is old enough that I'm sure there really is a
memory allocation or pointer problem in there. But I need to use it
from vs2008 and I can't get the dll changed.
Any thoughts about what changed in vs2008 that might have caused this,
and what I might be able to do to work around it?
If it helps, the call to the main processing method looks like this:
[DllImport("foo.dll", EntryPoint = "foo")]
protected static extern void foo(ref InputData inputData, ref
OutputData outputData);
The InputData and OutputData are structures that include old fortran
style fixed arrays and types. They're quite large, so I won't post
the whole thing uless you think it's important. But here's a subset
as an example:
[StructLayout(LayoutKind.Sequential)]
public struct OutputData
{
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 10)]
public char[] Version;
public int ValidSolution;
public int ErrorNo;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 500)]
public char[] ErrorMessage;
public int NumberOfUnits;
}
Thanks in advance for your help.
fortran dll from c# in vs2008 express, but the same code worked fine
in vs2005.
If I create a vs2005 c# wrapper dll to call the old fortran dll, then
I get the exception if I call that wrapper dll from a vs2008 console
app, but not if I call it from a vs2005 console app. I've tried
changing the vs2008 code to target the 2.0 framework, but I still get
the exception. This is all done on the same machine.
I'm running Xpsp2, so I don't think it's the data execution prevention
issue. I tried using editbin to change the nxcomp bit in console app
exe anyway, but it didn't make any difference. I also tried
explicitly excluding that console app exe from the dep through the
control panel, and that didn't make any difference either.
I can call a couple of simple utility methods on the dll without
getting the exception, but when I call the main processing method then
it happens. The dll is old enough that I'm sure there really is a
memory allocation or pointer problem in there. But I need to use it
from vs2008 and I can't get the dll changed.
Any thoughts about what changed in vs2008 that might have caused this,
and what I might be able to do to work around it?
If it helps, the call to the main processing method looks like this:
[DllImport("foo.dll", EntryPoint = "foo")]
protected static extern void foo(ref InputData inputData, ref
OutputData outputData);
The InputData and OutputData are structures that include old fortran
style fixed arrays and types. They're quite large, so I won't post
the whole thing uless you think it's important. But here's a subset
as an example:
[StructLayout(LayoutKind.Sequential)]
public struct OutputData
{
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 10)]
public char[] Version;
public int ValidSolution;
public int ErrorNo;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 500)]
public char[] ErrorMessage;
public int NumberOfUnits;
}
Thanks in advance for your help.