Windows Service written in Visual Studio 2022 won't start

king_moot 1 Reputation point
2022-05-09T08:01:54.933+00:00

Hi, I have written a windows service using Visual Studio 2022. The service utilises an IBM Library that was pulled into the project using Visual Studio's NuGet package manager.

I tested the code beforehand by writing a class library and testing it in a class module (vb). It worked once the IBM Library was pulled into the Console Application via the NuGet package manager.

I want to use this code as a windows service, so I wrote a Service, and pulled in the code. The class module has a single public sub which does all the work. The service calls that Sub. Again, I added the DLL to the project via the NuGet package manager.

When you compile the service, it appears to put the exe and related DLLs in the release folder.

I copied these files to a C:\Program Files\ area and installed the service using the .NET installutil utility.

However, when I run up the service, I get this error:

tmrService_Tick() failed:Could not load file or assembly 'amqmxmsstd, Version=9.2.5.0, Culture=neutral, PublicKeyToken=d2666ab12fca862b' or one of its dependencies. The system cannot find the file specified.

Interestingly, the compiled console application DOES work when I run the EXE...but I can't seem to get the service to start. How do I distribute the windows service exe and related DLLs so that the service will start?

If there are dependencies to amqmxmsstd, how would I work out what they are?

Developer technologies | VB
{count} votes

6 answers

Sort by: Most helpful
  1. king_moot 1 Reputation point
    2022-05-09T10:19:14.267+00:00

    Could it be that the DLLs have to be copied somewhere else on the server, rather than alongside the Service binary exe?

    Any ideas about that?

    0 comments No comments

  2. king_moot 1 Reputation point
    2022-05-09T10:26:05.093+00:00

    I have copied the amqmxmsstd DLL to C:\Windows\SysWOW64\

    I now get a different error:

    Faulting application name: MyService.exe, version: 1.0.0.0, time stamp: 0xda21fcfc
    Faulting module name: ntdll.dll, version: 10.0.19041.1566, time stamp: 0xbde09443
    Exception code: 0xc0000374
    Fault offset: 0x000e6d03
    Faulting process ID: 0x72e8
    Faulting application start time: 0x01d8638e9a147894
    Faulting application path: C:\Program Files\MyService\MyService.exe
    Faulting module path: C:\WINDOWS\SYSTEM32\ntdll.dll
    Report ID: b2756903-acc4-4e89-bc6d-fb0fd313a79d
    Faulting package full name:
    Faulting package-relative application ID:

    0 comments No comments

  3. Jiachen Li-MSFT 34,221 Reputation points Microsoft External Staff
    2022-05-10T08:21:28.217+00:00

    Hi @king_moot ,
    Check the following link to see if it helps.
    https://social.msdn.microsoft.com/Forums/vstudio/en-US/197aed35-544e-4047-965d-da6c3835e4a8/error-in-starting-windows-serviceservice-cannot-be-started-systemiofileloadexception-could-not?forum=netfxbcl
    Best Regards.
    Jiachen Li

    ----------

    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

  4. king_moot 1 Reputation point
    2022-05-10T08:52:10.65+00:00

    Hi, thanks but I don't think that's the same error. My error doesn't refer to "Assembly binding logging"

    0 comments No comments

  5. MotoX80 36,401 Reputation points
    2022-05-10T14:36:56.663+00:00

    I have copied the amqmxmsstd DLL to C:\Windows\SysWOW64\

    Is your service compiled as 32 bit and is that the 32 bit version of the amqmxmsstd.DLL?

    You might want to trace the service startup with process monitor.

    https://learn.microsoft.com/en-us/sysinternals/downloads/procmon

    I believe that when your service starts, the current working directory will be C:\Windows\system32 (or maybe syswow64 for 32 bit). If your dependent dll's are over in C:\Program Files\SomeDir, then Windows might not be able to find them. If the dll's are registered in the GAC, then they should be found.

    Tracing the startup with procmon will show you the dll's it's looking for and what directories it's searching.

    Did you also install a MQ client or MQ SDK? I don't know what's required these days. You might have to search the IBM.com documentation.

    I'll apologize in advance, it's been a number of years since I last wrote a service or played with MQ. Hope this helps.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.