Professional IronPython


clr.AddReferenceByPartialName(



Download 20,35 Mb.
Pdf ko'rish
bet142/453
Sana01.07.2022
Hajmi20,35 Mb.
#723045
1   ...   138   139   140   141   142   143   144   145   ...   453
clr.AddReferenceByPartialName(
PartialAssemblyName
)
: Adds a reference to the .NET 
assembly by passing a partial name that IronPython looks up in the GAC. This method doesn’t 
assure that you obtain any particular version of the assembly you need. You can use the
clr.AddReferenceByName()
method to better control which version of the assembly loads.
Now that you have a better idea of how to add a reference, let’s try importing the System.Xml 
assembly. The following steps help you get the assembly referenced and imported into IronPython.
1.
Type
import sys
and press Enter. This step makes the 
sys
module accessible.
2.
Type 
sys.path.append(‘C:\\WINDOWS\\Microsoft.NET\\Framework\\v2.0.50727‘)
and press Enter. In order to add a reference to an assembly, you must provide its location as 
part of 
sys.path
. You may need to change the drive and directory to match your system.
If you provide the wrong .NET Framework location, you can use the 
sys 
.path.remove()
 method to remove it from the list. For example, if you want 
to remove the .NET Framework 2.0 path, you type 
sys.path.remove(‘C:\\
WINDOWS\\Microsoft.NET\\Framework\\v2.0.50727‘)
 and press Enter. 
3.
Type 
import clr
and press Enter. This step makes the 
clr
module accessible, which has the 
various assembly reference methods described earlier.
4.
Type 
clr.AddReference(‘System.Xml.DLL‘)
and press Enter. IronPython now has a ref-
erence to the assembly file it needs, but the assembly isn’t imported yet. If you receive an IO 
Error message, it means that IronPython couldn’t find the assembly you requested in the loca-
tion provided as part of 
sys.path
.
5.
Type 
import System.Xml
and press Enter. The 
System.Xml
assembly is now available for 
use. It’s time to test to verify that the assembly is available.
6.
Type 
dir(System.Xml)
and press Enter. You should see the content of the 
System.Xml
assembly, as shown in Figure 7-9.
This technique works with any .NET assembly, not just those found in the GAC. If you have a custom 
.NET assembly you want to use in your application, this technique lets you access it with ease. Make 
sure you use the right technique for the kind of assembly you want to import. If version number is 
important, then make sure you use the 
clr.AddReferenceByName()
method.
548592c07.indd 125
2/25/10 9:44:27 AM
www.finebook.ir



Download 20,35 Mb.

Do'stlaringiz bilan baham:
1   ...   138   139   140   141   142   143   144   145   ...   453




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish