Excel stopped working, error 2147417851

Hehehe. Yup, the reboot of power has failed me :frowning:

Do you have any errors in Event Viewer>Windows Logs>System regarding DCOM around the time you start the service?

Not around the same time. But:

And this test you did here Excel stopped working, error 2147417851 - #19 by Colin_Morris was running as a service and not just from the ide in debug mode?

Correct.

This is proving a little difficult to test as I think I’m being blocked by the trial edition popup as the editions start. Still checking.

1 Like

I sort of have it working, its running through the debug output but its not cleaning up correctly and winword is staying running. Is your project being built as 32 or 64 bit? Have you tried the other?

I have not tried the other, I just hit the magic Build button. Will have to try adjusting that.

Ok, I got it working, it doesn’t seem to be the 32 or 64 it thing, it just seemed that way for a moment.

I have this output now when running as a service:

image

That is certainly what I want to be seeing. Do you have the steps you used to register the service?

Ah hold on, its running as local system, damn, let me change that user and retest.

Ok, its working as testuser

Earlier I had to reinstall Office Pro 2016 as the testuser I made to test this, I couldn’t get it working installing it as administrator then trying to run it as testuser.

Did you install it as the user and/or have you tried a reinstall of office?

I did have to make some component service changes and registry tweaks but I’m a bit lost as to why you aren’t seeing the errors I’m seeing in the event logs as I’ve mentioned above though, this lead me through to working out the issue, but if you don’t see them then I’m not really sure where it might be getting hooked up for you.

Have you installed any other office/reader software on the server, like foxit?

This was installed on my behalf by the server administrator, so it was not installed as myself. I have not installed any other office/ reader software on the server.

So you’re staying you’ve got testuser that’s running the app and it works, and you’ve installed it to run as a service and it works?

Yes, its running as testuser through as a Service as a console app built in xojo with the following code in App.Run:

' DEBUGGING
Dim excel As New ExcelApplication
dim StepMe as String
StepMe = "1"  

StepMe = StepMe + "3"  
System.DebugLog("Step 3")  
StepMe = StepMe + "." + excel.Version + "." 

System.DebugLog(StepMe)

#If Not DebugBuild Then // Do not try to daemonize a debug build
  If (args(1) = "start" Or args(1) = "-d") Then // Check for command-line parameter to daemonize
    system.DebugLog("starting daemon")
    If Not App.Daemonize Then
      System.Log( System.LogLevelCritical, "Could not daemonize the app.")
      Return -1
    End If
  End If
#Endif

I’ve just reverted all my changes and worked through each one now I have a working service example.

What I saw was this in Event Viewer:

which lead me to adding Local Activation for the user into Component Services>My Computer:

However if there isn’t the same trail then I don’t think it’ll help you much.

The only time I saw any COM error was when I installed office as administrator, then logged into the user and tried to run your code, compiled from the command line. That could have been because I changed from Home edition to Pro but the reinstall fixed that.

If you want to jump on Zoom or something and rubber duck me through your server while screen sharing, drop me a PM buy clicking on my portrait and clicking Message.

I will give that a try. I did some reading and https://documentation.xojo.com/api/language/consoleapplication.html#consoleapplication-daemonize only works on OsX/linunx there’s a ServiceApplication it says to use on Windows? So I am further confused :slight_smile:

@Wayne_Golding knows a lot more about Xojo’s service apps than probably anyone around he might be able to shed some light on that, but I just tweaked it until it stopped hanging on startup in services. Even when it was set as a ServiceApplication it was still not gracefully getting past the service start.

Here’s a copy of the [test project][LINK REMOVED PER OP REQUEST] (build with an older version of xojo as my licence has expired), it does nothing fancy like keep running, it just runs, does the excel test and quits and it was added as a service in an elevated cmd prompt with:

sc create Test BinPath="C:\Users\testuser\Desktop\test\Builds - untitled\Windows\My Application\My Application.exe"

We got it working after a quick Zoom call, it looks like it could have been something as simple as having an old unattached Excel running, possibly after a test went wrong. Killing that from task manager and running things seemed to work ok.

All the best Colin, I hope we don’t run into that one again :slight_smile:

And I got to play with services, com and office, ahh the memories :wink:

2 Likes