[python-win32] Problem on com server ony in a specifie application

Matteo Boscolo matteo.boscolo at boscolini.eu
Fri Jan 7 08:11:30 CET 2011


Hi all,

I made the following test:
I create a c# application that call the some method
//code
             object obj = Activator.CreateInstance
                 (Type.GetTypeFromProgID("test.Application"));
             object[] objArgs = new object[1];
             objArgs[0] = "ciao";
             obj.GetType().InvokeMember("comInit",
                 BindingFlags.InvokeMethod, null, obj, objArgs);

             object ret=obj.GetType().InvokeMember("Now",
                 BindingFlags.InvokeMethod, null, obj, objArgs);

If I compile the code under any cpu I got the some problem that in 
thinkdesing
If I compile the code under 32Bit cpu I have no error and the com server 
works well ..

So now my question is :
Can I manage this situation under python code ?

The strange think is if I use the anyCpu compilation the method Now 
works without any problem...!??!?

Regards,
Matteo


Il 06/01/2011 21:05, Tim Roberts ha scritto:
> Matteo Boscolo wrote:
>> how can I understand how to fix this problem ?
>>
>> It's quite a strange behaviour,
>> this is the method that fails, and it fails only if the argument is != None
>>
>>       def comInit(self,obj=None):
>>           if obj==None:
>>               return "ss" + str(test1)
>>           else:
>>               self._obj=test1(obj)
>>               return self._obj
> What do you expect this to do?  You are returning a Python object as the
> return value of a COM method.  What do you expect a C program to do with
> this object?  The Python COM support isn't going to know how to create a
> wrapper for this.  If you need to return a new object, then that object
> should be a Python COM object as well.
>



More information about the python-win32 mailing list