dbatools icon indicating copy to clipboard operation
dbatools copied to clipboard

`Remove-DbaReplArticle` - Unable to find type `[Microsoft.SqlServer.Replication.Article]`

Open mattcargile opened this issue 8 months ago • 1 comments

Verified issue does not already exist?

I have searched and found no existing issue

What error did you receive?

Unable to find type [Microsoft.SqlServer.Replication.Article]

Steps to Reproduce

Import-Module dbatools
Get-Help *defrag* # Error
Get-Help Microsoft.SqlServer.Replication.Article # Error
Get-Command Remove-DbaReplArticle -mo dbatools | ForEach-Object -MemberName get_Parameters # Error

Please confirm that you are running the most recent version of dbatools

2.1.30

Other details or mentions

Consider dropping the function for now to avoid the error.

What PowerShell host was used when producing this error

PowerShell Core (pwsh.exe), Windows PowerShell (powershell.exe)

PowerShell Host Version

Name                           Value
----                           -----
PSVersion                      7.5.0
PSEdition                      Core
GitCommitId                    7.5.0
OS                             Microsoft Windows 10.0.22631
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

SQL Server Edition and Build number

Not Applicable

.NET Framework Version

.NET 9.0.1

mattcargile avatar Apr 29 '25 00:04 mattcargile

I quite "second this" . I fear we're crumbling under the weight of shipping every possible dll out there, with the result of being stuck for months trying to keep dbatools.library "shippable". The adverse effect is that the whole dbatools module suffers just for a few "advanced functions" . Till MS fixes some incompatibilities or we figure out the mysteries behind assembly loading context, I vouch for a leaner dbatools.library and removing those "advanced" functions from dbatools alltogether.

@potatoqualitee , do you concur ?

niphlod avatar May 05 '25 21:05 niphlod

yeah, this should have been dbatools.replication like dbatools.ssis. not most as new modules, but many. nevertheless. we should just mark those as incompat with core, as microsoft does not support it.

potatoqualitee avatar Jul 20 '25 07:07 potatoqualitee

@claude

ipmo "C:\gallery\dbatools.library\desktop\lib\Microsoft.SqlServer.Replication.dll"
[Microsoft.SqlServer.Replication.Article]
InvalidOperation: Unable to find type [Microsoft.SqlServer.Replication.Article].
ipmo "C:\gallery\dbatools.library\desktop\lib\Microsoft.SqlServer.RMO.dll"
[Microsoft.SqlServer.Replication.Article]

IsPublic IsSerial Name                                     BaseType
-------- -------- ----                                     --------
True     False    Article                                  Microsoft.SqlServer.Replica…

pls fix, rmo is in our lib. do minimal changes. i dont want to globally load, just command specific. to reduce the amount of time it takes to import dbatools. i think thats the way the other commands work.

make pr

potatoqualitee avatar Oct 29 '25 18:10 potatoqualitee

Claude finished @potatoqualitee's task —— View job • claude/issue-9655-20251029-1826 • Create PR ➔


Tasks Completed

  • [x] Locate the Remove-DbaReplArticle command file
  • [x] Examine similar replication commands for DLL loading patterns
  • [x] Implement command-specific RMO DLL loading
  • [x] Commit and push changes
  • [x] Provide PR creation URL

Summary

Fixed the Remove-DbaReplArticle command by adding the Add-ReplicationLibrary call to the begin block. This ensures that Microsoft.SqlServer.Rmo.dll is loaded before the [Microsoft.SqlServer.Replication.Article] type is used, resolving the "Unable to find type" error.

The fix follows the same pattern used by other replication commands in dbatools (like Get-DbaReplArticle) and keeps the library loading command-specific to avoid impacting module import performance.

Changes Made

File: public/Remove-DbaReplArticle.ps1

  • Added Add-ReplicationLibrary call at line 96 in the begin block

--- | Branch: claude/issue-9655-20251029-1826

claude[bot] avatar Oct 29 '25 18:10 claude[bot]