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

C# WPF Calling DLL - Unhandled exception of type 'System.EntryPointNotFoundException'

Jacqueline_N_
Beginner
1,773 Views

I have created a solution MYAPP.  Within the solution I have a C# WPF (MYAPP) and a Fortran DLL (MYDLL).  A wrapper class (MYWRAPPERCL) calls the Fortran DLL.

 

When I attempt to call the DLL I receive the following message:

 

An unhandled exception of type ‘System.EntryPointNotFoundException’ occurred in MYAPP.exe

 

Additional information: Unable to find an entry point name ‘MYENTRYPT’ in DLL ‘c:\Users\me\My Documents\Visual Studio 2013\Projects\MYAPP\MYDLL\Debug\MYDLL.dll’

 

Here is what I have checked so far; nothing changes the error message:

 

1 - I have altered the call to the DLL as:

   [DllImport(“c:\\Users\\me\\My Documents\\Visual Studio 2013\\Projects\\MYAPP\\MYDLL\ \Debug\\MYDLL.dll",   EntryPoint = "MYENTRYPT", SetLastError = true,

        CharSet = CharSet.Unicode, ExactSpelling = true,

        CallingConvention = CallingConvention.StdCall)]

        public static extern int MYENTRYPT();

 

2 - I have altered the call to the DLL as:

   [DllImport("c:\\Users\\me\\Documents\\Visual Studio 2013\\Projects\\MYAPP\\MYDLL\\Debug\\MYDLL.dll",   EntryPoint = "MYENTRYPT", SetLastError = true,

        CharSet = CharSet.Unicode, ExactSpelling = true,

        CallingConvention = CallingConvention.StdCall)]

        public static extern int MYENTRYPT();

 

3 - I have altered the call to the DLL as:

   [DllImport("MYDLL.dll",   EntryPoint = "MYENTRYPT", SetLastError = true,

        CharSet = CharSet.Unicode, ExactSpelling = true,

        CallingConvention = CallingConvention.StdCall)]

        public static extern int MYENTRYPT();

 

4 - In Solution Explorer/Properties the Project Folder for the MYDLL is set to:

      c:\Users\me\Documents\Visual Studio 2013\Projects\MYAPP\MYDLL\

 

5 - I verified that the DLL is located in: 

     c:\Users\me\My Documents\Visual Studio 2013\Projects\MYAPP\MYDLL\Debug

 

6 - Linker command line for MYDLL:

/OUT:"Debug\PMC.dll" /VERBOSE /INCREMENTAL:NO /NOLOGO /MANIFEST /MANIFESTFILE:"Debug\MYDLL.dll.intermediate.manifest" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:"C:\Users\me\Documents\Visual Studio 2013\Projects\MYAPP\MYDLL\Debug\MYDLL.pdb" /SUBSYSTEM:WINDOWS /IMPLIB:"C:\Users\me\Documents\Visual Studio 2013\Projects\MYAPP\MYDLL\Debug\MYDLL.lib" /DLL

 

History

- Other projects (other than dll) compiled and run from the Projects subdirectory compile and execute without exception.

- At one point in time I renamed the DLL folder to MYDLL; was able to compile and link successfully after the change.  

 

 

0 Kudos
3 Replies
Steven_L_Intel1
Employee
1,773 Views

You haven't shown what the Fortran source for MYENTRYPT looks like (including any directives). It is unlikely that changing the calling convention to Stdcall is appropriate, unless perhaps the Fortran project is something migrated from Compaq Visual Fortran. If you run DependencyWalker on your DLL, what does it show for the names of the exported entry points?

The other thing to look at is whether all the dependent DLLs are present. C#, VB and the like will give you "entry point not found" when the real problem is that some dependent DLL is not present. You would typically not see this on a system where Intel Fortran is installed, but if you copied the DLL elsewhere without installing the redistributable installers you might.

0 Kudos
Jacqueline_N_
Beginner
1,773 Views

Thank you for your response Steve,

I didn't include the source as I thought it was a load/scope issue.  However, as it turns out, it was an entry point issue; which I would not have found if you hadn't pointed me in the right direction - thx.

I had Dependency Walker installed and had previously interrogated the DLL but missed the fact that my entry point module was absent!  I had originally installed Dependency Walker to look at the marshaling of names to ensure accuracy of my calls.  In any event, yes, the module was a Compaq Visual Fortran that was migrated; application was a VB app calling Compaq Visual Fortran DLL. In Compaq Visual Fortran DLL I did not need to identify the called module as a subroutine; complete INTERFACE and !DEC$ statements were sufficient. 

To Fix the issue I:

1 - Added a subroutine statement to the Fortran code:

    SUBROUTINE MYENTRYPT/END SUBROUTINE 

2 - Retained the existing statement within the MYDLL module:      

        !DEC$ ATTRIBUTES DLLEXPORT, ALIAS: '_MYENTRYPT'::MYENTRYPT

3 - Rebuilt the application and was able to run :)

 

 

 

 

0 Kudos
Steven_L_Intel1
Employee
1,773 Views

Ok - Please make sure that under Fortran > External procedures, Calling Convention is set to Default and not CVF. I don't understand your comment about having to add SUBROUTINE - there's no difference from CVF there. But I'm glad you got it working.

0 Kudos
Reply