Error with Phidget22 on SBC2

General PhidgetSBC Discussion.
TestUzer
Phidgetsian
Posts: 9
Joined: Thu Jan 18, 2018 7:13 am
Contact:

Error with Phidget22 on SBC2

Postby TestUzer » Thu Jan 18, 2018 8:17 am

I was upgrading some C# code to work with the Phidget22 library on an SBC2, and it refuses to compile. Narrowed the problem down to the following distilled code.

Code: Select all

using System;
using System.IO;
using System.Text;

using Phidget22;
using Phidget22.Events;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            Manager manager = new Manager();

            try
            {
                manager.Attach += new ManagerAttachEventHandler(manager_Attach);
                manager.Detach += new ManagerDetachEventHandler(manager_Detach);
            }
            catch (PhidgetException ex)
            {
                Console.WriteLine( "Opps {0} {1}", ex.ErrorCode, ex.Description );
            }


            manager.Open();

            manager.Close();
            manager = null;

        }

        static void manager_Attach(object sender, ManagerAttachEventArgs e)
        {
        }

        static void manager_Detach(object sender, ManagerDetachEventArgs e)
        {
        }


    }
}



If the two lines
manager.Attach += new ManagerAttachEventHandler(manager_Attach);
manager.Detach += new ManagerDetachEventHandler(manager_Detach);

are rem'd out it will compile and run on the SBC2, but with either of them included I get the following compiler error for 'mcs'

Code: Select all

root@phidgetsbc:~# mcs -r:Phidget22.NET.dll  x.cs

** (/usr/lib/mono/1.0/mcs.exe:14565): WARNING **: Missing method .ctor in assembly /root/Phidget22.NET.dll, type System.Runtime.CompilerServices.CompilerGeneratedAttribute

** (/usr/lib/mono/1.0/mcs.exe:14565): WARNING **: The class System.Runtime.CompilerServices.CompilerGeneratedAttribute could not be loaded, used in Phidget22.NET

** (/usr/lib/mono/1.0/mcs.exe:14565): WARNING **: Can't find custom attr constructor image: /root/Phidget22.NET.dll mtoken: 0x0a000010
Internal compiler error at x.cs(12,21):: exception caught while emitting MethodBuilder [Program::Main]

Unhandled Exception: System.TypeLoadException: Could not load type 'System.Runtime.CompilerServices.CompilerGeneratedAttribute' from assembly 'Phidget22.NET'.
  at System.MonoCustomAttrs.GetCustomAttributesBase (ICustomAttributeProvider obj, System.Type attributeType) [0x00000] in <filename unknown>:0
  at System.MonoCustomAttrs.GetCustomAttributes (ICustomAttributeProvider obj, System.Type attributeType, Boolean inherit) [0x00000] in <filename unknown>:0
  at System.Reflection.MonoMethod.GetCustomAttributes (System.Type attributeType, Boolean inherit) [0x00000] in <filename unknown>:0
  at Mono.CSharp.AttributeTester.IsConditionalMethodExcluded (System.Reflection.MethodBase mb, Location loc) [0x00000] in <filename unknown>:0
  at Mono.CSharp.Invocation.IsMethodExcluded (System.Reflection.MethodBase method, Location loc) [0x00000] in <filename unknown>:0
  at Mono.CSharp.Invocation.EmitCall (Mono.CSharp.EmitContext ec, Boolean is_base, Mono.CSharp.Expression instance_expr, System.Reflection.MethodBase method, Mono.CSharp.Arguments Arguments, Location loc, Boolean dup_args, Boolean omit_args) [0x00000] in <filename unknown>:0
  at Mono.CSharp.Invocation.EmitCall (Mono.CSharp.EmitContext ec, Boolean is_base, Mono.CSharp.Expression instance_expr, System.Reflection.MethodBase method, Mono.CSharp.Arguments Arguments, Location loc) [0x00000] in <filename unknown>:0
  at Mono.CSharp.EventExpr.EmitAddOrRemove (Mono.CSharp.EmitContext ec, Boolean is_add, Mono.CSharp.Expression source) [0x00000] in <filename unknown>:0
  at Mono.CSharp.EventAddOrRemove.EmitStatement (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0
  at Mono.CSharp.StatementExpression.DoEmit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0
  at Mono.CSharp.Statement.Emit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0
  at Mono.CSharp.Block.DoEmit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0
  at Mono.CSharp.Block.Emit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0
  at Mono.CSharp.ExplicitBlock.Emit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0
  at Mono.CSharp.TryCatch.DoEmit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0
  at Mono.CSharp.Statement.Emit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0
  at Mono.CSharp.Block.DoEmit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0
  at Mono.CSharp.Block.Emit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0
  at Mono.CSharp.ExplicitBlock.Emit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0
  at Mono.CSharp.ToplevelBlock.Emit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0
  at Mono.CSharp.MethodData.Emit (Mono.CSharp.DeclSpace parent) [0x00000] in <filename unknown>:0
  at Mono.CSharp.MethodOrOperator.Emit () [0x00000] in <filename unknown>:0
  at Mono.CSharp.Method.Emit () [0x00000] in <filename unknown>:0



and for 'gmcs'

Code: Select all

root@phidgetsbc:~# gmcs -r:Phidget22.NET.dll  x.cs

** (/usr/lib/mono/2.0/gmcs.exe:14786): WARNING **: Missing method .ctor in assembly /root/Phidget22.NET.dll, type System.Runtime.Versioning.TargetFrameworkAttribute

** (/usr/lib/mono/2.0/gmcs.exe:14786): WARNING **: The class System.Runtime.Versioning.TargetFrameworkAttribute could not be loaded, used in Phidget22.NET

** (/usr/lib/mono/2.0/gmcs.exe:14786): WARNING **: Can't find custom attr constructor image: /root/Phidget22.NET.dll mtoken: 0x0a00000e

Unhandled Exception: System.TypeLoadException: Could not load type 'System.Runtime.Versioning.TargetFrameworkAttribute' from assembly 'Phidget22.NET'.
  at System.Reflection.Assembly.GetType (System.String name, Boolean throwOnError, Boolean ignoreCase) [0x00000] in <filename unknown>:0
  at System.Reflection.Assembly.GetType (System.String name) [0x00000] in <filename unknown>:0
  at Mono.CSharp.RootNamespace.GetTypeInAssembly (System.Reflection.Assembly assembly, System.String name) [0x00000] in <filename unknown>:0
  at Mono.CSharp.RootNamespace.LookupTypeReflection (Mono.CSharp.CompilerContext ctx, System.String name, Location loc, Boolean must_be_unique) [0x00000] in <filename unknown>:0
  at Mono.CSharp.GlobalRootNamespace.LookupTypeReflection (Mono.CSharp.CompilerContext ctx, System.String name, Location loc, Boolean must_be_unique) [0x00000] in <filename unknown>:0
  at Mono.CSharp.Namespace.LookupType (Mono.CSharp.CompilerContext ctx, System.String name, Location loc) [0x00000] in <filename unknown>:0
  at Mono.CSharp.Namespace.Lookup (Mono.CSharp.CompilerContext ctx, System.String name, Location loc) [0x00000] in <filename unknown>:0
  at Mono.CSharp.TypeManager.CoreLookupType (Mono.CSharp.CompilerContext ctx, System.String ns_name, System.String name, Kind type_kind, Boolean required) [0x00000] in <filename unknown>:0
  at Mono.CSharp.TypeManager.InitCoreTypes (Mono.CSharp.CompilerContext ctx) [0x00000] in <filename unknown>:0
  at Mono.CSharp.Driver.Compile () [0x00000] in <filename unknown>:0
  at Mono.CSharp.Driver.Main (System.String[] args) [0x00000] in <filename unknown>:0


How do I fix this?

Return to “General”

Who is online

Users browsing this forum: No registered users and 1 guest