Unable to cast object
of type 'Microsoft.SqlServer.Management.Smo.SimpleObjectKey' to type
I ran into this error for the first time a few hours ago [more]and I have no idea what's causing it since I've been creating SQL Jobs for some time except for the past few days. Maybe some patch or update or an installation somewhere but I really can't tell what. Sorry bout that.
the SqlServer.Management namespace somehow indicates that the issue is with the management (client) tool and you're right.
The good news though is that there are a number of information available online suggesting that this is usually encountered if you're trying to run an SSIS package inside an SQL scheduled job. Funny thing though is that I wasn't trying to do that. Instead I'm getting an error simply by trying to create a job (with or without steps). The cause is generally associated with having the SQL Server patched wtih SP2 but the client tool used for creating the job was not patched by SP2. Once again, funny thing is that I was trying to create the job on the same machine and if I did apply the patch, I'm sure I would have applied it for client components too.
So the issues discussed in the articles/posts did not exactly match the scenario I'm in but I figured I should check and install SP2 anyway. And when I ran the SP2 executable it displayed to me the components that it detected and the patch can be applied to. In my case, all of the components (server and client side). So for short SP2 was never ran on that machine. The mention that the mismatch between the versions of the client and server might have been true but this shows that there could be other causes.
Nevertheless, installed SP2 and the error went away. Not a scientific discovery there but just FYI for those who might ignore that possible fix since the posts mention only of running SSIS packages inside the job. Then again as always, explore all possible options and if you can't really be certain that it would be the fix, make this the last resort. Although it is always recommended to apply services packs anyway so whether it fixes your issue or not, plan on applying it anyway.
Now I can finish some things I'm preparing for my next posts.