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

COM Server and C#

bcartolo
Beginner
232 Views
I want to do a com server and use assumed shape arrays, but after several hours I still cant manage to make it works.
Visual Studio crashes every time I run the solution.
I have two projects.
The fortran project is an in-process server and the method inside the class is as follows:
[fortran]function IFortranCOM_SumAssumedMatrices( ObjectData ,&
         a,&
         b,&
         c) result (hresult)
    use FortranCOM_Types
    implicit none
    type(FortranCOM_InstanceData) ObjectData
    !dec$ attributes reference :: ObjectData
    REAL(8), intent(in) :: a
    DIMENSION a(1:,1:)
    REAL(8), intent(in) :: b
    DIMENSION b(1:,1:)
    REAL(8), intent(out) :: c
    DIMENSION c(1:,1:)
    integer(long) hresult
    !  DO NOT REMOVE THIS LINE
    c=a+b
    hresult = S_OK
    !  DO NOT REMOVE THIS LINE
end function[/fortran]
The COM Hierarchy Editor looks like this:
Screen1.png
Screen2.png
SumNumbers works fine and SumMatrices (fixed sized arrays) also works fine. The only problem here is that the matrix indeces start at 1 instead of 0 in C#, which is odd, but at least it works!
In the C# console project I add the fortran dll as a reference and try to call the method
[csharp]using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CSharp
{
    class Program
    {
        static void Main(string[] args)
        {
            FortranCOMLib.IFortranCOM Kernel = new FortranCOMLib.FortranCOMClass();


            Double[,] Out = Kernel.SumAssumedMatrices(new Double[,] { { 1, 2 }, { 3, 4 } }, new Double[,] { { 1, 2 }, { 3, 4 } });

        }
    }
}[/csharp]
The program crashes without any debug information.
I have attached the whole solution aswell.
The most frustrating part is that I remember being able to use assumed shape arrays before with fortran 11 but unfortunately I have no trace of how I did it.
Any Idea????
0 Kudos
0 Replies
Reply