0

So I'm trying to build an executable. The project I'm running is building on X86.

When I build the project, everything seems fine and I get an executable. But the executable doesn't run. I get an error saying:

'child' is not a child control of this parent.

Followed by, Exception:

Class not registered (Exception from HRESULT: 0X80040154 (REGDB_E_CLASSNOTREG).

I made sure everything is X86 and I cleaned the solution and rebuilt. But I still get these errors. (I tried switching to X64 and Any PC and those options can't even located my DeviceBase.dll) When I started debugging, it took me straight to a specific function of the code.

protected override void Call(bool calling)
{            
    if (calling)
    {
        if (components != null)
        {
            components.Call();
        }                    
    }

    //This is where I get the exception saying
    //cannot access a called object
    base.Call(calling);
}

The Stack trace gives me something like this:

Message=Cannot access a disposed object.
Object name: 'Icon'.
ObjectName=Icon
Source=System.Drawing

The components starts off as null, and calling is initially false. How can I handle this exception in a proper manner? Any advice is appreciated.

LoLance
  • 25,666
  • 1
  • 39
  • 73
  • 1
    There is not nearly enough information here to help. Please include a [MCVE] – maccettura Mar 26 '19 at 19:43
  • 1
    Possible duplicate of [How to solve COM Exception Class not registered (Exception from HRESULT: 0x80040154 (REGDB\_E\_CLASSNOTREG))?](https://stackoverflow.com/questions/1496214/how-to-solve-com-exception-class-not-registered-exception-from-hresult-0x80040) – Odrai Mar 26 '19 at 19:43
  • @Odrai not sure if that is caused by the exception in the function though. Maybe it's my lack of knowledge, but hopefully you can explain why. – Quack Space Marine Mar 26 '19 at 19:53
  • Please set the project platform target to x86. Since most of the COM you may be using in your project was built on x86. Project Properties-->Build-->Target Platform-->x86. I think the 'access a disposed object' error is a result of a previous failure. – Odrai Mar 26 '19 at 19:58
  • @Odrai Question: so since I'm building my project in X64 PC, I decided to switch everything to X64 (since x86 doesn't work). But now I get a different error saying, "Could not load file or assembly 'DeviceBase, Version=3.2.0.1903, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format." I checked the path, everything is right, then why do I get this error? – Quack Space Marine Mar 26 '19 at 20:23
  • Maybe this [similar issue](https://stackoverflow.com/questions/2023766/an-attempt-was-made-to-load-a-program-with-an-incorrect-format-even-when-the-p) could do some help? – LoLance Mar 27 '19 at 10:58
  • If you [enable Fusion logs](https://stackoverflow.com/questions/255669/how-to-enable-assembly-bind-failure-logging-fusion-in-net) you will see very specific information on the problem, including the specific file that is at issue. – John Wu Mar 28 '19 at 07:42

1 Answers1

0

Thanks for everyone's help. But I had to get device software specific files (.dlls) and set embed interop types to false. That did the trick.