Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28543 Discussions

C# / Fortran mixed-language in VS2005 - build problems

David_Rowe
Beginner
278 Views

Hello,

I'm writing my first mixed-language application in Visual Studio 2005, using IVF 10.0. I have a single solution with two projects. The first project is the main program,a console application written in C#. The second project is a DLL, written in Fortran, called by the main program. Two unrelated (?) problems/questions:

  1. If I clean the solution, then press the "start debugging" button, all seems to work OK. It builds, and I can step through with the debugger. However, if I clean the solution, then build, and then attempt to start debugging, the solution starts building again, and this time the Fortran project build fails with the message"Error: The operation could not be completed" (and no other diagnostics that I can see).
  2. Howshould I arrange things so that theC# main program can find the Fortran DLL at debug time? At the moment, I've set the debug working folder of the main program project to be the output folder of the DLL project, but that seems a little clumsy. Is there a better way?

Any comments / advice appreciated,

David

0 Kudos
4 Replies
Steven_L_Intel1
Employee
278 Views
I recommend against setting the output folder of one project to be that of another - it causes problems on a rebuild. Instead, add a Post-build step that copies the DLL into the project directory of the executable.
0 Kudos
David_Rowe
Beginner
278 Views

Steve,

Thanks for your comments. I take your point about it not being a good idea to have two projects sharing the same output folder. However, that isn't quite what I was doing - apologies if my original post was unclear. To ensure that the main program can find the DLL, all that I've done is to set the Working Directory for debugging the main program (in Properties|Debug|Start-Options for the main program project in the VS2005 IDE). I now think this is workable and safe. An alternative, I guess, would be to alter my path environment variable so that the DLL is on the general DLL search path.

I tried your suggestion of copying the DLL into the debug/bin folder of the main project. This does enable the solution to build and run OK. However, it means you can't step the debugger through the main C# code and then down into the Fortran DLL code - the debugger complains that it can't find the Fortran source files (presumably due to the DLL having been moved).

As for Item 1 in my original post, the odd build errors, I now think that this is an unrelated problem, associated with build order and dependencies. In my solution, I mistakenly had the main program project marked as being dependent on the DLL project. If I remove that dependency, the problem goes away. That's OK for my present purposes, but I think it's probably a bug that ought to be followed up. It can be reproduced, in VS2005, as follows:

1. Start a new project, using the Intel-Fortran|Library|Dynamic-link-library-with-sample-code template.

2. Add a second project to the solution, using the Visual-C#|Windows|Console-Application template.

3. In Project Dependencies, mark the console application proejct as dependent on the DLL project.

4. Build the solution. (Builds OK).

5. Press F5 to start debugging. Errors are displayed as follows.

Error: The operation could not be completed

------ Build started: Project: ConsoleApplication1, Configuration: Debug Any CPU ------

Build started 07/09/2007 13:01:03.

Target CopyFilesToOutputDirectory:

ConsoleApplication1 -> C:DCRjobsgnocis2007 workformula parserinterfacingDll2ConsoleApplication1inDebugConsoleApplication1.exe

Build succeeded.

Time Elapsed 00:00:00.10

========== Build: 1 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

The problem occurs with VS2005, but not with VS2003. It's also demonstrable (again in VS2005 but not VS2003) with the "VB.NET-SafeArrays" sample provided as part of the Intel Fortran installation.

Is this something I should report through Premier Support?

David

0 Kudos
Steven_L_Intel1
Employee
278 Views
David,

I don't see exactly what you do, but I note that you did not set the console project as the "Startup project". If you don't, then the step-into tries to run the DLL and gives an error. This would be the same in VS2003, so you seem to be seeing something different.

I have not had debugging problems when I copy the DLL.

If you are still seeing a problem, please do report it and attach a ZIP file of your solution/projects.
0 Kudos
David_Rowe
Beginner
278 Views

Steve,

Updated for the record. I reported the problem to Intel Premier Support, but they couldn't reproduce it. And, on a clean machine (VS2005 and IVF 10.0 only), neither could I. I've since moved to a new development machine, on which the problem doesn't occur either. I've put it down to something odd about the configuration of my old machine - possibly the presence of multiple versions of Visual Studio and/or IVF running side-by-side.

David

0 Kudos
Reply