RobotStudio event

PC SDK Compability Issues

Options


PC SDK compability issues
If you are getting:
[quote]TypeInitializationException was unhandled

The type initializer for 'ABB.Robotics.Controllers.Internal.ControllerManager' threw an exception.
InnerException: System.IO.FileLoadException

Mixed mode assembly is built against version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information.[/quote]
or
[quote]BadImageFormatException was unhandled

The type initializer for 'ABB.Robotics.Controllers.Internal.ControllerManager' threw an exception.
InnerException: System.BadImageFormatException

Could not load file or assembly 'ABB.Robotics.Adapters.IRC5, Version=5.xx, Culture=neutral, PublicKeyToken=xx' or one of its dependencies. An attempt was made to load a program with an incorrect format.[/quote]
Then this is for you.

Background
At the core of the controller communication of the PC SDK there is some old managed code created in the days when the IRC5 was new. ABB is working on replacing it but is not there yet. This means that in the mean time the PCSDK does not yet come in a 64-bit nor a .NET 4 version. Instead it is built for 32bit and with .NET Framework 2.
This makes it a bit troublesome for a developer who wants to do a PC SDK Windows form app straight away. This since you need to tell the development environment what to do with this old stuff.Solution for mixing with .NET Framework 4.xUsing the PC SDK dll references together with a newer .NET 4.x project will generate a TypeInitializationException runtime error. You could solve this by downgrading the whole project to a .NET Framework 2 project, but if you need/want those nifty .NET 4 features do this:Right click your project and select Add>New Item.In the dialog select Application Configuration File. In the App.config file you need to add code so that it looks like this:
[code]<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true"></startup>
</configuration>[/code]

Solution for AnyCPU / x64 / x86
Using the PC SDK controller communication on 64bit will generate a BadImageFormatException so you need to tell the project to run x86 exclusively. This means that even if you are running on a 64bit OS it will run the app as a 32bit process.
Right Click the project and select Properties.In the Build tab in the list Platform target: select x86

 

Comments

  • baijun
    Options
    PC SDK compability issues If you are getting: [quote]TypeInitializationException was unhandled
    The type initializer for 'ABB.Robotics.Controllers.Internal.ControllerManager' threw an exception. InnerException: System.IO.FileLoadException
    Mixed mode assembly is built against version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information.[/quote] or [quote]BadImageFormatException was unhandled
    The type initializer for 'ABB.Robotics.Controllers.Internal.ControllerManager' threw an exception. InnerException: System.BadImageFormatException
    Could not load file or assembly 'ABB.Robotics.Adapters.IRC5, Version=5.xx, Culture=neutral, PublicKeyToken=xx' or one of its dependencies. An attempt was made to load a program with an incorrect format.[/quote] Then this is for you. Background At the core of the controller communication of the PC SDK there is some old managed code created in the days when the IRC5 was new. ABB is working on replacing it but is not there yet. This means that in the mean time the PCSDK does not yet come in a 64-bit nor a .NET 4 version. Instead it is built for 32bit and with .NET Framework 2. This makes it a bit troublesome for a developer who wants to do a PC SDK Windows form app straight away. This since you need to tell the development environment what to do with this old stuff.Solution for mixing with .NET Framework 4.xUsing the PC SDK dll references together with a newer .NET 4.x project will generate a TypeInitializationException runtime error. You could solve this by downgrading the whole project to a .NET Framework 2 project, but if you need/want those nifty .NET 4 features do this:Right click your project and select Add>New Item.In the dialog select Application Configuration File. In the App.config file you need to add code so that it looks like this:
    [code]<?xml version="1.0" encoding="utf-8" ?>
    <configuration>
    <startup useLegacyV2RuntimeActivationPolicy="true"></startup>
    </configuration>[/code]

    Solution for AnyCPU / x64 / x86

    Using the PC SDK controller communication on 64bit will generate a BadImageFormatException so you need to tell the project to run x86 exclusively. This means that even if you are running on a 64bit OS it will run the app as a 32bit process.

    1. Right Click the project and select Properties.
    2. In the Build tab in the list Platform target: select x86

     

    Hi John Wiberg ,thank you for your attention.I am new in using PC SDK,failed in initialization of NetworkScanner class ,my project is set to X86, ABB.Robotics.Controllers.PC.dll version 6.3.7016.2009, the same as Robot Communication Runtime. May I ask you, what is the problem and what is the solution, thank you very much.








  • baijun
    Options
    Hi John Wiberg.
        I have a question, ABB dll requires .NET version 4.5, how to downgrade the project to the .NET version 2.0? .NET Downgrade to version 2.0, the compiler will complain. I am by your practice to add the code in the App.config file you mentioned, suggesting that error, I am using VS2013, it has been set for the x86 platform.
        So much I am looking forward to your reply.