I'm currently trying to consume a FORTRAN DLL that I have been given by a third party. Now, it has been consumed before by other vendors (unsure whether they used C# or not to consume it), but I'm getting some reference errors when I'm trying to consume it.
I'm basically trying to get it to work within a small test app.
Here's the C# code I'm using to import (basic COM really):
[DllImport("foo.dll")]
public static extern void foo(ref int IS, ref double[] BETA, ref int K, out double TH, out double SETH, out int IER);
static void Main(string[] args)
{
double[] betas = new double[3];
betas[0] = 25.6;
betas[1] = 30.8;
betas[2] = 35.8;
int score = 5;
int numberOfItems = 3;
double latentVariable;
double standardErrorOfEstimate;
int errorCode;
foo(ref score, ref betas, ref numberOfItems, out latentVariable, out standardErrorOfEstimate, out errorCode);
Console.ReadLine();
}
Note: The DLL method signature matches that what I have.
When trying to run the application, I get the following Exception:
Unable to load DLL 'foo.dll': The application has failed to start because its side-by-side configuration is incorrect. Please see the application event log or use the command-line sxstrace.exe tool for more detail. (Exception from HRESULT: 0x800736B1)
Looking in the event log, the following details is shown on the error:
Activation context generation failed for "C:\dllpath\foo.dll". Dependent Assembly Microsoft.VC90.DebugCRT,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="9.0.21022.8" could not be found. Please use sxstrace.exe for detailed diagnosis.
Also, running sxstrace, the same information and error is shown:
ERROR: Cannot resolve reference Microsoft.VC90.DebugCRT,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="9.0.21022.8". ERROR: Activation Context generation failed. End Activation Context Generation.
Now, after doing some googling and looking round on here, some people recommend installing the Redistributable packages for C++. I've done that for both 2008 and 2010 on both x86 and x64 platforms and still no joy.
Anyone got any ideas? I'm using Visual Studio 2010 and Windows 7 (if that helps?).
ref
keyword for arrays. They already are references. Only add theref
keyword to primitive values. – John AlexiouFORTRAN
function declaration with arguments and types please. – John Alexiou