https://wiki.bananeatomic.fr/index.php?title=Assembly&feed=atom&action=history
Assembly - Historique des versions
2024-03-29T05:51:08Z
Historique des versions pour cette page sur le wiki
MediaWiki 1.39.5
https://wiki.bananeatomic.fr/index.php?title=Assembly&diff=25416&oldid=prev
Nicolas : /* Obtenir la version */
2021-03-16T21:48:46Z
<p><span dir="auto"><span class="autocomment">Obtenir la version</span></span></p>
<table style="background-color: #fff; color: #202122;" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="fr">
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Version précédente</td>
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Version du 16 mars 2021 à 21:48</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l23">Ligne 23 :</td>
<td colspan="2" class="diff-lineno">Ligne 23 :</td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>GetType().Assembly.GetName().Version.ToString();</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>GetType().Assembly.GetName().Version.ToString();</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>Assembly.GetEntryAssembly().GetName().Version.ToString();</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>Assembly.GetEntryAssembly().GetName().Version.ToString();</div></td></tr>
<tr><td colspan="2" class="diff-side-deleted"></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"></ins></div></td></tr>
<tr><td colspan="2" class="diff-side-deleted"></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;">var simplifiedVersion = Regex.Replace(version, "(\\.0)+$", string.Empty);</ins></div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div></kode></div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div></kode></div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br/></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br/></td></tr>
</table>
Nicolas
https://wiki.bananeatomic.fr/index.php?title=Assembly&diff=24639&oldid=prev
Nicolas : /* Obtenir la version */
2020-11-15T15:34:55Z
<p><span dir="auto"><span class="autocomment">Obtenir la version</span></span></p>
<table style="background-color: #fff; color: #202122;" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="fr">
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Version précédente</td>
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Version du 15 novembre 2020 à 15:34</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l21">Ligne 21 :</td>
<td colspan="2" class="diff-lineno">Ligne 21 :</td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>= Obtenir la version =</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>= Obtenir la version =</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div><kode lang=csharp></div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div><kode lang=csharp></div></td></tr>
<tr><td colspan="2" class="diff-side-deleted"></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;">GetType().Assembly.GetName().Version.ToString();</ins></div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>Assembly.GetEntryAssembly().GetName().Version.ToString();</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>Assembly.GetEntryAssembly().GetName().Version.ToString();</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div></kode></div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div></kode></div></td></tr>
<tr><td colspan="2" class="diff-side-deleted"></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"></ins></div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div><kode lang=powershell></div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div><kode lang=powershell></div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>[Reflection.AssemblyName]::GetAssemblyName('MonAssembly.dll').Version</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>[Reflection.AssemblyName]::GetAssemblyName('MonAssembly.dll').Version</div></td></tr>
</table>
Nicolas
https://wiki.bananeatomic.fr/index.php?title=Assembly&diff=21733&oldid=prev
Nicolas : /* OnAssemblyResolve */
2019-09-04T09:38:52Z
<p><span dir="auto"><span class="autocomment">OnAssemblyResolve</span></span></p>
<p><b>Nouvelle page</b></p><div>[[Category:CSharp]]<br />
= [https://docs.microsoft.com/en-us/dotnet/framework/deployment/how-the-runtime-locates-assemblies Comment le runtime cherche les assemblies] =<br />
# Assemblies already loaded<br />
# GAC<br />
# [https://docs.microsoft.com/en-us/dotnet/framework/configure-apps/file-schema/runtime/codebase-element codeBase]<br />
# Application's root directory<br />
## No culture information<br />
### {{boxx|[assembly name].dll}}<br />
### {{boxx|[assembly name] / [assembly name].dll}}<br />
## Culture information is specified for the referenced assembly<br />
### {{boxx|[culture] / [assembly name].dll}}<br />
### {{boxx|[culture] / [assembly name] / [assembly name].dll}}<br />
## [https://docs.microsoft.com/en-us/dotnet/framework/configure-apps/file-schema/runtime/probing-element privatePath] (sous dossiers)<br />
### No culture information<br />
#### {{boxx|[privatePath] / [assembly name].dll}}<br />
#### {{boxx|[privatePath] / [assembly name] / [assembly name].dll}}<br />
### Culture information is specified for the referenced assembly<br />
#### {{boxx|[privatePath] / [culture] / [assembly name].dll}}<br />
#### {{boxx|[privatePath] / [culture] / [assembly name] / [assembly name].dll}}<br />
<br />
= Obtenir la version =<br />
<kode lang=csharp><br />
Assembly.GetEntryAssembly().GetName().Version.ToString();<br />
</kode><br />
<kode lang=powershell><br />
[Reflection.AssemblyName]::GetAssemblyName('MonAssembly.dll').Version<br />
</kode><br />
<br />
= Assembly vs File vs Product version =<br />
* If Assembly version is not explictly specified, it takes the value of 0.0.0.0.<br />
* If File version is not explicitly specified, it takes the value of Assembly version.<br />
* If Product version is not explicitly specified, it takes the value of File version.<br />
<br />
= Assembly =<br />
<kode lang=csharp><br />
// L'exécutable<br />
Assembly entryAssembly = Assembly.GetEntryAssembly();<br />
// L'assemblage en cours d'exécution<br />
Assembly executingAssembly = Assembly.GetExecutingAssembly();<br />
// L'assemblage ayant appelé la méthode en cours d'exécution<br />
Assembly callingAssembly = Assembly.GetCallingAssembly();<br />
<br />
// Charger une assembly depuis son nom<br />
Assembly assembly = Assembly.Load("Namespace.Class, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null");<br />
Assembly assembly = Assembly.LoadWithPartialName("Namespace.Class");<br />
<br />
// Charger une assembly depuis un de ses types<br />
Assembly assembly = Assembly.GetAssembly(typeof(Console));<br />
<br />
// chemin vers le fichier *.exe<br />
string path = Assembly.GetEntryAssembly().Location;<br />
// chemin vers le dossier contenant le fichier *.exe<br />
string folder = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);<br />
<br />
// Version<br />
Version assemblyVersion = Assembly.GetEntryAssembly().GetName().Version;<br />
string stringAssemblyVersion = assemblyVersion.ToString(); // "1.0.0.0"<br />
<br />
string fileVersion = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).FileVersion;<br />
string productVersion = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).ProductVersion;<br />
</kode><br />
<br />
== [https://blogs.msdn.microsoft.com/suzcook/2003/09/19/loadfile-vs-loadfrom LoadFile vs LoadFrom] ==<br />
* {{boxx|LoadFrom}} utilise Fusion et peut charger une autre assembly situé dans un autre chemin mais avec la même identité si celle-ci est déjà chargée dans le LoadFrom context.<br />
* {{boxx|LoadFile}} n'utilise pas Fusion, c'est exactement l'assembly demandé qui est chargée. Les dépendances ne sont pas automatiquement trouvées dans son dossier. Si elles ne sont pas disponibles dans le Load context, il faut utiliser l'event AssemblyResolve pour les lier.<br />
{| class="wikitable wtp" <br />
! Method<br />
! Advantages<br />
! Disadvantages<br />
|-<br />
| Load<br />
| Gets the benefits of versioning and policy.<br><br />
Dependencies available in the Load context are automatically found.<br />
| Dependencies in other contexts are not available unless you subscribe to the AppDomain.AssemblyResolve event.<br />
|-<br />
| LoadFrom<br />
| Assemblies can be loaded from multiple paths, not just from beneath the ApplicationBase.<br><br />
Dependencies already loaded in this context will automatically be found.<br><br />
Dependencies in the same dir as the requesting LoadFrom context assembly will automatically be found.<br />
| If a Load context assembly tries to load this assembly by display name, it will fail to be found, by default (e.g., when mscorlib.dll deserializes this assembly).<br><br />
Worse, an assembly with the same identity, but at a different path, could be found on the probing path, causing an InvalidCastException, MissingMethodException, or unexpected method behavior, later on.<br><br />
If an assembly by the same identity is already loaded, you’ll get that one back, even if you’ve specified a path to a different one.<br><br />
It does a FileIOPermission.Read + PathDiscovery demand, or a WebPermission demand, on the path/URL specified.<br />
|-<br />
| LoadFile<br />
| Avoids probing costs for loading this assembly.<br><br />
You can load multiple assemblies with the same identity into the same appdomain.<br />
| Nothing can bind to this assembly unless you’ve subscribed to the AssemblyResolve event.<br><br />
Dependencies can only be loaded from the Load context or using the AssemblyResolve event.<br><br />
Passing this assembly to another AppDomain may become tricky (e.g., when this is a Reflection Emit assembly that hasn’t been saved).<br />
|}<br />
[https://codingarchitect.wordpress.com/2006/09/11/assembly-load-vs-loadfile-vs-loadfrom Assembly.Load vs LoadFile vs LoadFrom]<br />
<br />
== OnAssemblyResolve ==<br />
<kode lang='cs'><br />
AppDomain.CurrentDomain.AssemblyResolve += OnAssemblyResolve;<br />
</kode><br />
<br />
== [https://docs.microsoft.com/en-us/dotnet/framework/tools/fuslogvw-exe-assembly-binding-log-viewer Fuslogvw.exe (Assembly Binding Log Viewer)] ==<br />
<br />
= Attributs de l'assemblage =<br />
<kode lang="cs"><br />
// Description<br />
object[] attributes = _assembly.GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false);<br />
if (attributes.Length != 0)<br />
{<br />
string description = ((AssemblyDescriptionAttribute)attributes[0]).Description;<br />
}<br />
<br />
// Product<br />
object[] attributes = _assembly.GetCustomAttributes(typeof(AssemblyProductAttribute), false);<br />
if (attributes.Length != 0)<br />
{<br />
string product = ((AssemblyProductAttribute)attributes[0]).Product;<br />
}<br />
<br />
// Copyright<br />
object[] attributes = _assembly.GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false);<br />
if (attributes.Length != 0)<br />
{<br />
string copyright = ((AssemblyCopyrightAttribute)attributes[0]).Copyright;<br />
}<br />
<br />
// Company<br />
object[] attributes = _assembly.GetCustomAttributes(typeof(AssemblyCompanyAttribute), false);<br />
if (attributes.Length != 0)<br />
{<br />
string company= ((AssemblyCompanyAttribute)attributes[0]).Company;<br />
}<br />
<br />
// Guid<br />
object[] attributes = _assembly.GetCustomAttributes(typeof(GuidAttribute), false);<br />
if (attributes.Length != 0)<br />
{<br />
string guid = ((GuidAttribute)attributes[0]).Value;<br />
}<br />
<br />
// ClientCompany<br />
object[] attributes = _assembly.GetCustomAttributes(typeof(ClientCompanyAttribute), false);<br />
if (attributes.Length != 0)<br />
{<br />
string clientCompany= ((ClientCompanyAttribute)attributes[0]).ClientCompany;<br />
}<br />
</kode></div>
Nicolas