[Python.NET] Problem with System.ArgumentException in call to method from dll

Daniel Krause m.daniel.krause at googlemail.com
Wed Jan 23 19:07:48 CET 2013


I tried this approach:

class PyBitmapSource(BitmapSource):
    pass
bitmapsrc = PyBitmapSource()
print bitmapsrc

The console output does not really change:
TypeError: cannot instantiate abstract class



2013/1/23 Barton <barton at bcdesignswell.com>

> The Python.Runtime is a bit tricky when it comes to out parameters:
> In C# DateTime.TryParse(String, out DateTime) becomes
>
> >>> d = DateTime(0)    # just a dummy to call the method on
> >>> d2 = DateTime(0) # another dummy to satisfy the out parameter (could
> be the same instance, d)
> # d3 is were the result is passed out
> >>> result, d3 = d.TryParse("2013/01/22", d2)
> >>> d3.ToString()
> u'1/22/2013 12:00:00 AM'
> >>> # this is the same behavior as iPy
>
>
>
> I can't test this - I'm on Linux, but:
> Here you've given the type (class)
>
> from System.Windows.Media.Imaging import BitmapSource
> bitmapsrc = BitmapSource
> print bitmapsrc
> cam = xiCam()
> cam.OpenDevice(0)
> cam.SetParam(PRM.BUFFER_**POLICY, BUFF_POLICY.SAFE)
> cam.SetParam(PRM.IMAGE_DATA_**FORMAT,  IMG_FORMAT.MONO8)
> cam.StartAcquisition()
> timeout = 1000
> bitmapsrc = cam.GetImage(bitmapsrc, timeout)
> cam.StopAcquisition()
> ##
>
> Console output:
> <class 'System.Windows.Media.Imaging.**BitmapSource'>
>
> What you need is an instance, perhaps:
> bitmapsrc = BitmapSource() # or something to that effect.
>
>
> On 01/22/2013 11:58 AM, Daniel Krause wrote:
>
>> from System.Windows.Media.Imaging import BitmapSource
>> bitmapsrc = BitmapSource
>> print bitmapsrc
>> cam = xiCam()
>> cam.OpenDevice(0)
>> cam.SetParam(PRM.BUFFER_**POLICY, BUFF_POLICY.SAFE)
>> cam.SetParam(PRM.IMAGE_DATA_**FORMAT,  IMG_FORMAT.MONO8)
>> cam.StartAcquisition()
>> timeout = 1000
>> bitmapsrc = cam.GetImage(bitmapsrc, timeout)
>> cam.StopAcquisition()
>> ##
>>
>> Console output:
>> <class 'System.Windows.Media.Imaging.**BitmapSource'>
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pythondotnet/attachments/20130123/614ea81a/attachment.html>


More information about the PythonDotNet mailing list