RE: [Python.NET] Do assemblies need to be placed into the GAC
Brian, Thanks for that. We don't currently put our assemblies into the GAC because our ASP.NET app can (theoretically) support multiple versions on the one server machine. Each version lives in a separate sub-directory that then contains a 'bin' directory for the assembly DLLs. Although you *can* put multiple versions of the same component into the GAC (as long as the AssemblyVersion number is different), how would Python.NET distinguish these? Felix.
From: "Brian Lloyd" <brian@zope.com> To: "Felix McAllister" <felix_mcallister@hotmail.com>, <pythondotnet@python.org> Subject: RE: [Python.NET] Do assemblies need to be placed into the GAC Date: Wed, 29 Oct 2003 09:30:34 -0500
I'd like to use PythonNet to script some .NET assemblies we have. Must I place these into the GAC? I've tried to put the python script into the same directory as the assembly DLL but this doesn't work:
Hi Felix -
Right now to import an assembly it either needs to be in the GAC or in the "application directory" or a subdirectory thereof.
When running python, the application directory is the directory where python.exe lives, not the place where the script you are running lives.
One of the things I want to do for the final is see if there is a way to have the assembly loader use the python path (sys.path) when looking for assemblies.
Brian Lloyd brian@zope.com V.P. Engineering 540.361.1716 Zope Corporation http://www.zope.com
_________________________________________________________________ MSN 8 helps eliminate e-mail viruses. Get 2 months FREE*. http://join.msn.com/?page=features/virus
Thanks for that. We don't currently put our assemblies into the GAC because our ASP.NET app can (theoretically) support multiple versions on the one server machine. Each version lives in a separate sub-directory that then contains a 'bin' directory for the assembly DLLs.
Although you *can* put multiple versions of the same component into the GAC (as long as the AssemblyVersion number is different), how would Python.NET distinguish these?
Right now it uses Assembly.LoadWithPartialName, which seems (the docs are vague on this) to load the most recent version of an assembly that it can find. The ability to side-by-side load different versions of assemblies is one of the (relatively few) places where the matching of meta-models between Python and the CLR breaks down. Because Python import is name-based and unaware of any concept of versioned modules, my goal has been for 'implicit assembly loading' (loading as a result of import) to do something consistent and reasonable (i.e. load most recent available based on name). It is possible to load a specific version of an assembly - you would do something like: from CLR.System.Reflection import Assembly, AssemblyName name = AssemblyName(...) # set required version, etc. assembly = Assembly.Load(name) # now import namespaces from the loaded assembly Things get a lot more complicated if you need to load more than one version of a particular assembly (or more likely, you have a dependency on some library the does so). In this case, the names you access via the CLR modules will always come from the first version of the assembly loaded (which will always win in the internals of the runtime). That doesn't mean that you're hosed though - you just have to do more work to get the right versions of objects, a la: from CLR.System.Reflection import Assembly, AssemblyName from System import Activator name = AssemblyName(...) # get the right version assembly = Assembly.Load(name) type = assembly.GetType("QualifiedNameOf.TheTypeINeed") obj = Activator.CreateInstance(type) Hope that helps somewhat. BTW, these are all great questions and I'm making notes to put these things in the faq / docs :^) Brian Lloyd brian@zope.com V.P. Engineering 540.361.1716 Zope Corporation http://www.zope.com
Brian Lloyd wrote:
Thanks for that. We don't currently put our assemblies into the GAC because our ASP.NET app can (theoretically) support multiple versions on the one server machine. Each version lives in a separate sub-directory that then contains a 'bin' directory for the assembly DLLs.
Although you *can* put multiple versions of the same component into the GAC (as long as the AssemblyVersion number is different), how would Python.NET distinguish these?
Right now it uses Assembly.LoadWithPartialName, which seems (the docs are vague on this) to load the most recent version of an assembly that it can find.
The ability to side-by-side load different versions of assemblies is one of the (relatively few) places where the matching of meta-models between Python and the CLR breaks down.
Because Python import is name-based and unaware of any concept of versioned modules, my goal has been for 'implicit assembly loading' (loading as a result of import) to do something consistent and reasonable (i.e. load most recent available based on name).
It is possible to load a specific version of an assembly - you would do something like:
from CLR.System.Reflection import Assembly, AssemblyName
name = AssemblyName(...) # set required version, etc. assembly = Assembly.Load(name)
# now import namespaces from the loaded assembly
Things get a lot more complicated if you need to load more than one version of a particular assembly (or more likely, you have a dependency on some library the does so). In this case, the names you access via the CLR modules will always come from the first version of the assembly loaded (which will always win in the internals of the runtime).
That doesn't mean that you're hosed though - you just have to do more work to get the right versions of objects, a la:
from CLR.System.Reflection import Assembly, AssemblyName from System import Activator
name = AssemblyName(...) # get the right version assembly = Assembly.Load(name) type = assembly.GetType("QualifiedNameOf.TheTypeINeed") obj = Activator.CreateInstance(type)
Hope that helps somewhat. BTW, these are all great questions and I'm making notes to put these things in the faq / docs :^)
Brian Lloyd brian@zope.com V.P. Engineering 540.361.1716 Zope Corporation http://www.zope.com
_________________________________________________ Python.NET mailing list - PythonDotNet@python.org http://mail.python.org/mailman/listinfo/pythondotnet
Hi, Without knowing too much about the PythonDotNet environment (yet) I have just a general observation. Shouldn't the versioning knowledge be kept out of the source code? Totally!? When the containers/assemblies are instantiated the actual binding to a specific version should take place. Isn't there functionality in the assemblies to deal with that? regards, Folkert
participants (3)
-
Brian Lloyd -
Felix McAllister -
Folkert Boonstra