I have a Visual Studio project that has a VC++ .dll project, along with a C# Console Application and a C# service which both reference the VC++ .dll using this:
[DllImport("ImagingService.dll")]
public static extern int main();
In the Main()
method of the console app I call the main()
method of the .dll and everything works as expected.
In the C# service project I call the main()
method from within the OnStart()
method. If all I have for code is the return 0
in the VC++ application it returns 0 as expected. But, If I have code copied directly from this GitHub, I get an error like this:
System.DllNotFoundException: Unable to load DLL 'ImagingService.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
The console app is using the environment variables as expected to find the GStreamer
dependencies linked and included in the VC++ application, but it seems that the windows service is unable to find them. I know it finds the ImagingService.dll
because it works if I comment out the GStreamer
code.
Am I right in assuming that, since it works in the console app, all my includes are correct in the C++ app? And there is something different about how the service calls the GStreamer
dlls that fails.
UPDATE: Since there is question on how I have setup my service I have created a simple solution that includes a basic C++ dll and a C# service and a C# Console application. The console works fine, the service does not. If anyone is interested in looking it over I have included a download link.
You will also need to install the main x64 GStreamer installer and the x64 Devel package found here: Gstreamer Download
*NOTE *- when installing the main gstreamer-1.0 installer make sure you select to install the "restricted codecs with potential patent issues in some countries" option. You will also need to install the devel package as well.
For testing you can use VLC by typing the following into Media>OpenNetwork Stream text box.
rtsp://127.0.0.1:8554/test
Otherwise with the GStreamer installer they packaged the ability to run this command for testing:
gst-launch-1.0 rtspsrc location = rtsp://127.0.0.1:8554/test ! rtph264depay ! avdec_h264 ! autovideosink