RTFM 
http://ironpython.net/documentation/dotnet/dotnet.html#ref-and-out-parameters .

-----Original Message-----
From: Don Arnold <darnold992...@yahoo.com.dmarc.invalid>
Sent: Wednesday, April 30, 2014 0:39
To: ironpython-users@python.org <ironpython-users@python.org>
Cc: 
Subject: [Ironpython-users] issue creating object from third-party assembly

Hi! I'm having trouble understanding some weird behavior when trying to use an 
object defined in a third-party assembly. 
When I view the assembly in Object Explorer, I see that the CosEvent class 
defines two constructors.

One parameterless:
 
public CosEvent()
    Member of Cos.Core.EMS.CosEvent


And one parameterized:

public CosEvent(ref string prmPlatform, ref string prmProcessname, ref int 
prmProcessInstance, ref char prmEventType, ref int prmEventNumber, ref int 
prmErrorNumber, ref string prmEventDescription)
    Member of Cos.Core.EMS.CosEvent


So far, so good. But when I run the following test script:

import clr
import System

clr.AddReferenceToFileAndPath(r'c:\dll\CosEventManagement.dll')

import Cos.Core.EMS

print 50 * '-'
print '-- parameterless constructor'
print 50 * '-'
e = Cos.Core.EMS.CosEvent()
print type(e)
print e

print 50 * '-'
print '-- parameterized constructor with keyword params'
print 50 * '-'
e = Cos.Core.EMS.CosEvent(Platform='om5681d2',ProcessName='test 
process',ProcessInstance=1,EventType='S',EventNumber=1000,ErrorNumber=0,EventDescription='just
 another lousy test')
print type(e)
print e

print 50 * '-'
print '-- parameterized constructor with positional params'
print 50 * '-'
e = Cos.Core.EMS.CosEvent('om5681d2','test process',1,'S',1000,0,'just another 
lousy test')
print type(e)
print e


This is its output: 

--------------------------------------------------
-- parameterless constructor
--------------------------------------------------
<type 'CosEvent'>
<Cos.Core.EMS.CosEvent object at 0x000000000000002B [Cos.Core.EMS.CosEvent]>
--------------------------------------------------
-- parameterized constructor with keyword params
--------------------------------------------------
<type 'CosEvent'>
<Cos.Core.EMS.CosEvent object at 0x000000000000002C [Cos.Core.EMS.CosEvent]>
--------------------------------------------------
-- parameterized constructor with positional params
--------------------------------------------------
<type 'tuple'>
(<Cos.Core.EMS.CosEvent object at 0x000000000000002D [Cos.Core.EMS.CosEvent]>, '
om5681d2', 'test process', 1, <System.Char object at 0x000000000000002E [S]>, 10
00, 0, 'just another lousy test')


When I call the parameterless constructor, I get back a CosEvent object.
Likewise when I call the parameterized constructor using keyword parameters.
But when I call the parameterized constructor using positional parameters, I 
get a tuple containing the CosEvent object and its parameters.
And it's that third result that I'm not understanding...

Am I missing (or maybe just misunderstanding) something? Why do I get a tuple 
instead of just the 'naked' CosEvent object? And why does it only happen when I 
use positional parameters?

Any help you can give is greatly appreciated.

Thanks,
Don 
_______________________________________________
Ironpython-users mailing list
Ironpython-users@python.org
https://mail.python.org/mailman/listinfo/ironpython-users

_______________________________________________
Ironpython-users mailing list
Ironpython-users@python.org
https://mail.python.org/mailman/listinfo/ironpython-users

Reply via email to