- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm trying to get COM working from my Fortran application. I do a "COMINITIALIZE" followed by a "COMCreateObjectByProgID". Both of these appear to be successful andreturn a status of zero. However, when I try to use the COM object, I get "Unhandled exception at 0x00000000 in FortranProg01.exe: 0xC0000005: Access violation."
I realize that this error can mean almost anything, but has anyone got some suggestions of common problems with COM that produce this problem?
Here are some more details. My program code:
program FortranProg01
use myolepg
implicit none
integer*4 comInitStatus
integer:: comCreateStatus
INTEGER(INT_PTR_KIND()) $OBJECT
INTEGER(4) funcResult
REAL(8) pkgVersion
call COMINITIALIZE(comInitStatus)
print *, comInitStatus
call COMCreateObjectByProgID('MyOlePg.MyOlePkg', $OBJECT, comCreateStatus)
print *, comCreateStatus
funcResult = IMyOlePkg_GetPackageVersion($OBJECT, pkgVersion)
print *, funcResult
call COMUNINITIALIZE()
end program FortranProg01
The wizard-generated interface code:
INTERFACE
!property PackageVersion
INTEGER(4) FUNCTION IMyOlePkg_GetPackageVersion($OBJECT, pVal)
INTEGER(INT_PTR_KIND()), INTENT(IN) :: $OBJECT ! Object Pointer
!DEC$ ATTRIBUTES VALUE :: $OBJECT
REAL(8), INTENT(OUT) :: pVal
!DEC$ ATTRIBUTES REFERENCE :: pVal
!DEC$ ATTRIBUTES STDCALL :: IMyOlePkg_GetPackageVersion
END FUNCTION IMyOlePkg_GetPackageVersion
END INTERFACE
Thanks!
Brad.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2. Did you try to create an instance of your COM-object with a simple Visual Basic or .NET application?
Best regards,
Sergey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
1. I have no idea how to use CoCreateInstance in Fortran, and have been unable to find an example.
2. It works perfectly from a .NET application.
Brad.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Now whereas I don't really like the warning, and I'd be happy if someone could explain both the warning and the two different calls, I have it working, and if I never get a satisfactoryexplanation, I can probably learn to live with that.
Thanks!
Brad.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Now whereas I don't really like the warning, and I'd be happy if someone could explain both the warning and the two different calls, I have it working, and if I never get a satisfactoryexplanation, I can probably learn to live with that.
Hi Brad,
This is only a warning and ifapplication works,results/outputs are consistent, I would say, the problem is solved.
Best regards,
Sergey

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page