[python-win32] Access to .NET components from Python (Was: Win32 COM starter book)

Jens B. Jorgensen jens.jorgensen@tallan.com
Fri, 20 Dec 2002 14:33:16 -0600


Jens B. Jorgensen wrote:

> Mark Hammond wrote:
>
>>> Compile with csc /target:library MyAssembly.cs, register with
>>> regasm MyAssembly.dll /tlb:MyAssembly.tlb, and try to test it. Nope,
>>> OLE error 0x80131522. Google tells me that this means I need my
>>> assembly in the same directory as the executable! (That's Python, not
>>> the script - so definitely not where I'd like to put my random DLLs).
>>>   
>>
>>
>> Yeah, this is .NET for you.  If you want it publically available, you 
>> must create a strongly named assembly and stick it in the GAC.  There 
>> are 2 choices - very public or very private.  However, the "very 
>> public" isn't as bad as it sounds - you are guaranteed to get the 
>> *except* object you compiled against, regardless of naming clashes, etc.
>>
> As an aside I was trying to do this same thing just to try it. I run 
> regasm but I *still* can't get the object to create itself. It doesn't 
> matter if the object is in the current directory or the python 
> directory (same dir as python.exe). It still doesn't find it and I get 
> 'Class not registered'. Is it absolutely necessary to stick it in the 
> gac in order to be able to create it? This doesn't make sense to me 
> because then why bother with regasm? I had regasm first do the .tlb 
> thing and that didn't work so I generated the reg file and added it 
> manually. 

[snip]

Ok, sorry, sorry. Jumped the gun. I take it all back. Apparently I only 
*thought* I copied the .Net assembly .dll into c:\Python22. I must not 
have because after messing around with everything else in the world (and 
learning all about the GAC and signing keys and such in the process) I 
went back and /again/ copied the assembly .dll into c:\Python22\ and of 
course this time all works just fine. Doh. Well, at least I learned a 
bunch of other stuff in the process.

-- 
Jens B. Jorgensen
jens.jorgensen@tallan.com

"With a focused commitment to our clients and our people, we deliver value through customized technology solutions"