Skip to content

Commit

Permalink
Registering the assembly in Windows COM system requires the `CodeBase…
Browse files Browse the repository at this point in the history
…` value

Suppresses the `SYSLIB0012: Assembly.CodeBase is obsolete` warning
  • Loading branch information
jozefizso committed Jun 9, 2024
1 parent 27f0e26 commit 723ec2e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Source/Excel/Tools/RealtimeDataServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,10 @@ private static void RegisterHandleCodebase(Type type, InstallScope scope)
bool isSystemComponent = location.IsMachineComponentTarget(scope);
Assembly thisAssembly = Assembly.GetAssembly(type);
string assemblyVersion = thisAssembly.GetName().Version.ToString();
#pragma warning disable SYSLIB0012 // Type or member is obsolete
// although `CodeBase` is obsolete, the COM registry value requires it
CodebaseAttribute.CreateValue(type.GUID, isSystemComponent, assemblyVersion, thisAssembly.CodeBase);
#pragma warning restore SYSLIB0012 // Type or member is obsolete

}
}
Expand Down
3 changes: 3 additions & 0 deletions Source/NetOffice/Tools/COMAddinRegisterHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,10 @@ public static void Proceed(Type type, string[] addinOfficeRegistryKey, InstallSc
{
Assembly thisAssembly = Assembly.GetAssembly(type);
string assemblyVersion = thisAssembly.GetName().Version.ToString();
#pragma warning disable SYSLIB0012 // Type or member is obsolete
// although `CodeBase` is obsolete, the COM registry value requires it
CodebaseAttribute.CreateValue(type.GUID, isSystemComponent, assemblyVersion, thisAssembly.CodeBase);
#pragma warning restore SYSLIB0012 // Type or member is obsolete
}
catch (Exception)
{
Expand Down
3 changes: 3 additions & 0 deletions Source/Word/Tools/DocumentInspectorBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,10 @@ private static void RegisterHandleCodebase(Type type, InstallScope scope)
bool isSystemComponent = location.IsMachineComponentTarget(scope);
Assembly thisAssembly = Assembly.GetAssembly(type);
string assemblyVersion = thisAssembly.GetName().Version.ToString();
#pragma warning disable SYSLIB0012 // Type or member is obsolete
// although `CodeBase` is obsolete, the COM registry value requires it
CodebaseAttribute.CreateValue(type.GUID, isSystemComponent, assemblyVersion, thisAssembly.CodeBase);
#pragma warning restore SYSLIB0012 // Type or member is obsolete

}
}
Expand Down

0 comments on commit 723ec2e

Please sign in to comment.