ImportError: Cannot import name CaptureLimitType

Discussions, Bug Reports and Issues related to Beta versions of SharpCap
Post Reply
JesusRL
Posts: 70
Joined: Wed Aug 05, 2020 4:36 pm
Location: Madrid

ImportError: Cannot import name CaptureLimitType

#1

Post by JesusRL »

Hi Robin,

Library problem in last version 3.3.7351

T&R
User avatar
admin
Site Admin
Posts: 13296
Joined: Sat Feb 11, 2017 3:52 pm
Location: Vale of the White Horse, UK
Contact:

Re: ImportError: Cannot import name CaptureLimitType

#2

Post by admin »

Sorry, been moving stuff about in the application.

try adding

Code: Select all

clr.AddReference("SharpCap.Interfaces")
from SharpCap.Interfaces import CaptureLimitType
I will see if I can work out a way to keep my internal changes and be compatible with old scripts.

cheers,

Robin
JesusRL
Posts: 70
Joined: Wed Aug 05, 2020 4:36 pm
Location: Madrid

Re: ImportError: Cannot import name CaptureLimitType

#3

Post by JesusRL »

Hi Robin,

Your solution works fine in the newest beta.

In prior beta and 3.2 raises this error

Code: Select all

Running script from \\Diskstation\datos\Referencia\ASTRO\SHARPCAP\BATCH.py
Traceback (most recent call last):
  File "<string>", line 11, in <module>
IOError: System.IO.IOException: Could not add reference to assembly SharpCap.Interfaces
   en IronPython.Runtime.ClrModule.AddReference(CodeContext context, String name)
   en IronPython.Runtime.ClrModule.AddReference(CodeContext context, Object reference)
   en IronPython.Runtime.ClrModule.AddReference(CodeContext context, Object[] references)
   en Microsoft.Scripting.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)
   en Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
   en Microsoft.Scripting.Interpreter.LightLambda.Run4[T0,T1,T2,T3,TRet](T0 arg0, T1 arg1, T2 arg2, T3 arg3)
   en System.Dynamic.UpdateDelegates.UpdateAndExecute3[T0,T1,T2,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2)
   en Microsoft.Scripting.Interpreter.DynamicInstruction`4.Run(InterpretedFrame frame)
   en Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
   en Microsoft.Scripting.Interpreter.LightLambda.Run2[T0,T1,TRet](T0 arg0, T1 arg1)
   en IronPython.Compiler.PythonScriptCode.RunWorker(CodeContext ctx)
   en IronPython.Compiler.PythonScriptCode.Run(Scope scope)
   en IronPython.Compiler.RuntimeScriptCode.InvokeTarget(Scope scope)
   en IronPython.Compiler.RuntimeScriptCode.Run(Scope scope)
   en Microsoft.Scripting.SourceUnit.Execute(Scope scope, ErrorSink errorSink)
   en Microsoft.Scripting.Hosting.ScriptSource.Execute(ScriptScope scope)
   en PythonConsoleControl.PythonConsole.ExecuteStatements(String scriptText) en C:\Documents\Source Code\ironlab\IronPythonConsole\PythonConsoleControl\PythonConsole.cs:línea 404
So ... works fine being incompatible with previous versions of the application

For me any solution is fine (I will mantain both versions of the script)

T&R
User avatar
admin
Site Admin
Posts: 13296
Joined: Sat Feb 11, 2017 3:52 pm
Location: Vale of the White Horse, UK
Contact:

Re: ImportError: Cannot import name CaptureLimitType

#4

Post by admin »

Hi,

I have added the clr.AddReference() call to the initialization code in SharpCap 3.3, so it will no longer be needed, which should let you go back to one version .

thanks

Robin
Post Reply