18 Replies Latest reply on Aug 20, 2010 1:23 AM by RF2009

    using Vista, VS2008, C# or VB.NET

      I am using Vista, VS2008, C# or VB.NET trying to use what I was using under XP and W2K3. Below is a simple call that is not working under Vista?

      Error message Unable to cast COM object of type 'InDesign.ApplicationClass' to interface type 'InDesign._Application'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{ABD4CBB2-0CFE-11D1-801D-0060B03C02E4}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).

      namespace Demo1
      class Program
      static void Main(string[] args)
      InDesign.Application app = new InDesign.ApplicationClass();
      bool bVisible = app.Visible;

      Module Module1

      Sub Main()

      Dim app As New InDesign.Application
      Dim bVisible = app.Visible

      End Sub

      End Module
        • 1. Re: using Vista, VS2008, C# or VB.NET
          Level 1
          I have resolved this. Basically the installation of InDesign CS3 on Vista doesn't register the COM interfaces in the registry. Once I registered all the interfaces everything is working.
          • 2. Re: using Vista, VS2008, C# or VB.NET
            Could you tell us how you did that ?
            I am having the same issue here.
            • 3. Re: using Vista, VS2008, C# or VB.NET
              Did anyone manage to get this working? Which COM interfaces need to be registered, and how do you do this?


              • 4. Re: using Vista, VS2008, C# or VB.NET
                Level 1
                When something that works on XP fails in Vista, it's usually because of a file/folder permissions issue. When you go to Project>Add Reference in Visual C#, and then click the COM tab, are you able to see the Adobe InDesign CS3 type library? If not, click the Browse tab and locate the Resources for VisualBasic.tlb file (you might have to use Search to find it). Can you load this file? If not, try checking the permissions to the file.


                • 5. Re: using Vista, VS2008, C# or VB.NET
                  Level 1
                  This seems to make a lot of sense. It all seems to work now and I'm not sure why. I tried to re-register the InDesign exe and it may have been this which made it work. I have two copies of the tlb file now, one in my own c:\user\ directory, which on Vista gives me full rights. I think the problem is with permissions.

                  • 6. Re: using Vista, VS2008, C# or VB.NET
                    Level 1
                    I have the same problem for a month now and it drives me nuts.
                    I cannot add a reference to resources for Visual Basic.tlb to VS 2003 the way you describe, at least not by Browse.
                    VS keeps indicating that it can't and that the file is either not accessible or is not a valid assembly or COM component.
                    I have full Administrative rights, allowed full access to the user directory and all its sub folders, made several copies of the tlb and tried to load them, run VS 2005 as Administrator, with no luck.
                    How do I "register all the COM interfaces" as Robert Bozetto describes in his post ?
                    • 7. Re: using Vista, VS2008, C# or VB.NET
                      Level 1
                      How did you re-register Indesign.exe (I tried regsvr32 indesign.exe, says indesign.exe is loaded but entrypoint DllRegisterserver not found).
                      Still can't create reference to Resources for VB.tlb from VS2005.
                      • 8. Re: using Vista, VS2008, C# or VB.NET
                        Level 1
                        Just managed to register the tlb at least so it seems; it appears that the Resources for VB.tlb file was damaged (maybe because i tried to register it earlier with regsvr32 or by upgrading InDesign to 5.0.2 ?). I could repair it from a recovery version (at last Vista did something for me) and could reference it by Browse.

                        But now I receive an error in VS2003 which says that the System_COM variable can't be converted to interfacetype InDesign.Application; Interface not supported.

                        What to do now ? How to register all COM interfaces ?
                        • 9. Re: using Vista, VS2008, C# or VB.NET
                          Level 1
                          I'm not absolutely sure how I managed to get it to work. I opened a cmd window as adminstrtaor (type cmd in Start, right click cmd shortcut and pick Run as Administrator). In then browsed to InDesign.exe and tried to use regsvr32.exe, however exe has no entry point, so I tried running InDesign.exe directly from command prompt (some exe's self register). I think it was this bit which worked - i.e. InDesign running under administrator from command prompt appears to re-initialise and register COM interfaces.
                          • 10. Re: using Vista, VS2008, C# or VB.NET
                            Level 1
                            By the way, the code above will not work, you need to use CreateObject and cast back (the second line may wrap in this message):

                            Type oType = Type.GetTypeFromProgID("InDesign.Application");
                            InDesign.Application app = (InDesign.Application) Activator.CreateInstance(oType);

                            It looks like many of the API calls return objects which need to be cast, so you need to work out what you are getting back. This is not nice from a developer perspective. What would be really nice is if Adobe released a .NET version of the API with returns which represented interfaces not a generic object. In .NET, C# does not support optional parameters (you have to fill-in all the parameters), but VB.NET does, so watch out for this. JavaScript doesn't care, and the ExtendScript toolkit does not look like much help - no code completion or intellisense as far as I can see.
                            • 11. Re: using Vista, VS2008, C# or VB.NET
                              Level 1
                              Hi EricMc,

                              Hm. The ExtendScript Toolkit that comes with CS3 has both code completion and intellisense, but it can be kind of slow. You have to have targeted InDesign from the pop-up menu at the upper-left of the ESTK editor window--otherwise, it's not connected to the DOM. Let me know if you've targeted InDesign and it's still not working for you.

                              InDesign scripting supports AppleScript, VBScript, and ExtendScript, and is loosly typed by design. The farther you go from those languages, and the more you attempt to employ strong typing, the more trouble you'll have.

                              I do have to do some investigatino with Vista, though--all I know right now is that connecting to the COM library works fine for me from C# Express on a Vista VMWare machine. I'll keep trying (as time permits--which it mostly doesn't) to get it to fail, but these installs take a long time!


                              • 12. Re: using Vista, VS2008, C# or VB.NET
                                Level 1
                                Hello EricMC,

                                Tried your suggestion on starting InDesign.exe from the command prompt; it makes the .tlb file refresh, but does not solve my problem.
                                when i try your code ported to VB.NET the result is still the same; .NET keeps sayubf the COM interface cannot be started with the indicated CLID.

                                Suggestions anyone (other than skipping the idea to do this in Vista)?
                                • 13. Re: using Vista, VS2008, C# or VB.NET
                                  After looking at registry I found that COM interfaces it requests are indeed not registered.
                                  When trying to register "Resources for Visual Basic.tlb" manually Vista gave "the module may not compatible..." error.
                                  Fourtunately I found this great post by Jeff Klassen,
                                  Go there and get the reg file to import the registry.
                                  • 14. Re: using Vista, VS2008, C# or VB.NET
                                    Level 1
                                    Err, in addition to my previous post, I did not do registration of tlb correctly. So instead of importing reg file you should be able to just run command line as Administrator and run this: regtlb.exe "c:\ProgramData\Adobe\InDesign\Version 5.0\Scripting Support\5.0\Resources for Visual Basic.tlb"
                                    • 15. Re: using Vista, VS2008, C# or VB.NET
                                      Level 1
                                      Thanks for your post Anna and hats off for Jeff Klassen; I finally can run my software to control InDesign on Vista now after using his .reg file.
                                      Strange enough this error is still not solved by Adobe, at least not in the 5.0.3 update I just installed.....
                                      • 16. Re: using Vista, VS2008, C# or VB.NET
                                        Level 1
                                        Hi Roelof,

                                        re: "Strange enough this error is still not solved by Adobe, at least not in the 5.0.3 update I just installed....."

                                        I'm sorry, why should Adobe fix a "problem" with an unsupported language? How can Adobe fix a problem that has to do with user permissions in Vista?


                                        • 17. Re: using Vista, VS2008, C# or VB.NET
                                          RorohikoKris-u5pUJw Level 2
                                          Hi All,

                                          I bumped into this same problem and tried a few of the solutions above, but it did not work. I've then come up with the following amended procedure that does seem to work - no need to download anything (I don't like downloading 'wild' files of uncertain origin).

                                          1) Start a Command line window as Administrator (I am using the 'classic' start menu, and I do: Click Start button -> Programs -> Accessories -> Command Prompt.
                                          Right click the 'Command Prompt' entry. Select 'Run as administrator')

                                          2) Delete Resources for Visual Basic.tlb. To do that I typed:

                                          CD "%ALLUSERSPROFILE%\Adobe\InDesign\Version 5.0\Scripting Support\5.0"

                                          Then type

                                          REN "Resources for Visual Basic.tlb" "Resources for Visual Basic.tlb.old"

                                          This moves the existing file out of the way without actually deleting it

                                          3) Launch InDesign.exe - type:

                                          "C:\Program Files\Adobe\Adobe InDesign CS3\InDesign.exe"

                                          Let InDesign come up and stabilize itself. Then Exit it again

                                          4) Verify a new tlb file has been created - type


                                          A new file "Resources for Visual Basic.tlb" should be shown next to the old one

                                          5) Exit out of the command line window - type


                                          Now things should be working - at least, they did for me...
                                          • 18. Re: using Vista, VS2008, C# or VB.NET
                                            RF2009 Level 1

                                            Hello all


                                            Just wanted to share my findings on how to resolve this issue.


                                            I recently received this error when trying to run InDesign Server CS4. The server starts correctly, but I could not connect to it via my .NET service.


                                            I received this error:


                                            Unhandled Exception: System.Runtime.InteropServices.COMException (0x800401E4):
                                            nvalid syntax (Exception from HRESULT: 0x800401E4 (MK_E_SYNTAX))
                                               at System.Runtime.InteropServices.Marshal.MkParseDisplayName(IBindCtx pbc, S
                                            ring szUserName, UInt32& pchEaten, IMoniker& ppmk)
                                               at System.Runtime.InteropServices.Marshal.BindToMoniker(String monikerName)


                                            To fix this issue, I found out that you must delete the directory mentioned above:


                                            CD "%ALLUSERSPROFILE%\Adobe\InDesign\Version 5.0\Scripting Support\5.0"

                                            Obviously, not this directory, but the equivalent server version directory.

                                            If you are using multi instance, then delete does also.


                                            This is the important step:

                                            Make sure you run the InDesignServer.com with administrative rights (run as administrator).


                                            This rebuilds the scripting file and all should work.