Reply
Solved! Go to solution

COM Exception trying to use SEReader.dll C#

[ Edited ]

Greetings,

  I am trying to use SEReader (C# code) while debugging it throws a COM Exception when I try to assign the SEFileReader field.  I am very rusty on my C# and I assume I'm missing something simple but I've ran out of things to try, just spinning my wheels.

 

  • I registered the SEReader.dll per instructions in the word doc in the "Readers" dir of the SDK
  • We have ST6
  • I have set the Project configs for Debug to run on x86
  • I am confused about the CLSIDs I see, they are all different and frankly I don't know what that means.
    • The error references class ID  {C9165411-2A39-11D3-9273-00C04F79BE98}
    • the SEREADERLib reference properties shows Identity: {C9165401-2A39-11D3-9273-00C04F79BE98}\1.0\0\tlbimp
    • and regedit shows three other IDs

Capture.JPG

 

 

 

 

 

 

 

error message: 

An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in mscorlib.dll

Additional information: Retrieving the COM class factory for component with CLSID {C9165411-2A39-11D3-9273-00C04F79BE98} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).

 

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SEREADERLib;
using System.Runtime.InteropServices;

namespace seReaderTest
{
    class Program
    {
        static public Program prgm;
        static private SEREADERLib.SEFileReader seFileReader;
        static private SEREADERLib.Attachments children;
        static private SEREADERLib.Attachment child;
        static private System.Collections.IEnumerator childrenEnum;

        static void Main(string[] args)
        {
            prgm = new Program();
            
            seFileReader = new SEREADERLib.SEFileReader();
            string path = "C:/my.asm";
            seFileReader.Open(path);
            children = seFileReader.Attachments;
            childrenEnum = children.GetEnumerator();

            while (childrenEnum.MoveNext())
            {
                child = (SEREADERLib.Attachment)childrenEnum.Current;
                System.Console.WriteLine(child.ToString());
                //do other usefull stuff with the data in child.
            }
        }
    }
}

 

edit: Apologies for the multiple posts, cleaned up the extras. 

3 REPLIES

Re: COM Exception trying to use SEReader.dll C#

Silly me. 

found the problem, we had since gone to ST9.  Knowing ST9 is 64bit only I went and made this change and everything works. 

 

Project->~properties->Build tab->Platform  must be 64 bit.

Solution
Solution
Accepted by topic author bnemec
Monday

Re: COM Exception trying to use SEReader.dll C#

Also, [STAThread] attribute on Main() is important.

Jason Newell
Applications Architect
www.jasonnewell.net

Re: COM Exception trying to use SEReader.dll C#

Thank you Jason.  I recognized that attribute, but didn't understand what it does/is for.  So I looked it up and confirmed my staning assumption it had something to do with single thread...  but kept reading more and Windows Forms came up.  That's when it dawned on me, the first test project I started to gain a little understanding of how the SEReader lib worked was a console project, and I tried everything I could find to make it work with no avail.  This time around I used a Forms project because I had some other "building blocks" I was working on.  When it gave me the same exception I eventually worked to the 64bit option and then it worked.  Well, Visual Studio put the STAThread attribute on main() for me in the forms project.  So I go back to the non-working console app, fix some of the other settings I had buggered, add the STAThread attribute to main() and away we go.

Thanks again for the help.  It seems when I cannot find an answer it's because I'm not asking the right question; and once\if I figure out the right question the answer is right there in front of me.  It usually takes someone with good experience to come along and point me in the right direction.