none
Specified Cast is not Valid Error when opening run-as account properties

    Question

  • Environment is SCOM2012, patched to CU1.

    Went in this morning to add some new nodes to distribute our special SQL run-as account to some new computers recently added to monitoring. 

    Double-clicking the account in the console gives an immediate pop-up with the message:  'Specified cast is not valid'.  After I clear the message, my normal properties window appears but on the Distribution tab, all of my computers are gone (it's blank).  I dare not add and save for fear of overwriting my list.  Has anyone seen this?  I'm not sure what would have caused this.  We have added and deleted a few computers in the last month but it's been weeks since I last had to perform this operation.  The details of the message are below.  Thanks for any help.

    C

    ----------------------

    Note:  The following information was gathered when the operation was attempted.  The information may appear cryptic but provides context for the error.  The application will continue to run.

    System.InvalidCastException: Specified cast is not valid.
       at Microsoft.EnterpriseManagement.Monitoring.Internal.MonitoringObjectGenerated.get_Id()
       at Microsoft.EnterpriseManagement.Common.EnterpriseManagementObject.GetObjectWrappersPostProcessing[T](ReadOnlyCollection`1 resultSet, IEnterpriseManagementObjectCreatable`1 constructorHelper)
       at Microsoft.EnterpriseManagement.Common.EnterpriseManagementObject.CreateMultiple[T](IList`1 dataAccessResultSet, EnterpriseManagementGroup managementGroup, Dictionary`2& instanceById, ObjectQueryOptions queryOptions)
       at Microsoft.EnterpriseManagement.Common.EnterpriseManagementObject.CreateMultiple[T](IList`1 dataAccessResultSet, EnterpriseManagementGroup managementGroup, ObjectQueryOptions queryOptions)
       at Microsoft.EnterpriseManagement.SecurityConfigurationManagement.GetApprovedHealthServicesForDistribution[T](ISecuredData securedData)
       at Microsoft.EnterpriseManagement.Mom.Internal.UI.Common.SDKHelper.<>c__DisplayClass2b.<GetApprovedHealthServicesForDistribution>b__2a(Object sender, ConsoleJobEventArgs e)
       at Microsoft.EnterpriseManagement.Mom.Internal.UI.Console.ConsoleJobExceptionHandler.ExecuteJob(IComponent component, EventHandler`1 job, Object sender, ConsoleJobEventArgs args)

    Monday, July 16, 2012 5:07 PM

Answers

  • This problem is apparently fixed in UR5 for 2012 R2!

    http://support.microsoft.com/kb/3023138

    RunAs accounts cannot be edited because of "Specified cast is invalid" exception

    RunAs accounts can be distributed only to a selected computer through the distribution tab of Run As Account properties. When a computer that is in the distribution list is decommissioned from Operations Manager and the Run As account is opened, you receive the following exception, and no computers are shown on the list:

    System.InvalidCastException: Specified cast is not valid.    at Microsoft.EnterpriseManagement.Monitoring.Internal.MonitoringObjectGenerated.get_Id()

    Has anyone verified that this UR fixes the issue?

    • Proposed as answer by Jure Labrovic Wednesday, February 11, 2015 4:31 AM
    • Marked as answer by tx_cwf Wednesday, February 11, 2015 3:38 PM
    Wednesday, February 11, 2015 4:00 AM
  • Hello Jose,

    This exception comes in the console as a modal form.  The exception data is only what I've indicated at the beginning of this thread.  Clearing the exception allows operation to continue but when I get to the distribution list, it's empty.  Yet I know the relationships are there because otherwise I'd get hundreds of alerts for credentials not distributed. 

    I was running the console on a management server and was unable to locate a corresponding eventlog event in either the operations Manager, system, or application logs on the MS.

    I'm going to have to rebuild my list at this point.  My DBA's have been patiently standing by for some time now. 

    At best I can theorize that this was caused by one of the SQL Clusters we rebuilt (differently) without first removing the agentless and agent-based monitoring.

    Thanks for trying to help, Carl

    • Marked as answer by tx_cwf Thursday, July 26, 2012 3:14 PM
    Thursday, July 26, 2012 3:14 PM

All replies

  • Hello,

    It seems like a permission  issue. Which account do you use to do this action? The account should have correct permission to do it.

    Did you resolve this issue already? We’d love to hear your feedback about the solution. By sharing your experience you can help other community members facing similar problems.

    Thanks,


    Yog Li

    TechNet Community Support

    Monday, July 23, 2012 10:33 AM
    Moderator
  • Hi Yog,

    Thanks for responding.  No, it is not resolved though I thought it was.  Last Friday, it mysteriously cleared up and I was able to add 3 more hosts to my distribution list.  By evening however, it had ceased to function once again. 

    I am logged in as administrator on the local host.  I am a member of the SCOM Administrators group and have full permissions to execute all other administrative tasks in the console (or of course, I wouldn't even see the administration tab in the console).  There have been no changes of any kind to any of the accounts used by SCOM since this environment went live about 2 months ago.

    The situation becomes a bit more urgent each day as I'm unable to distribute credentials for fear of overwriting my existing list (over 150 hosts for the record).  However, if I can't figure it out, that's probably my next step because I can't delay monitoring on my sql servers much longer.

    If you have any ideas, I'll try anything!  Regards, Carl

    Monday, July 23, 2012 3:09 PM
  • Carl,

    Please export the complete event from the event log where you see that exception.

    unfortunately, the error "System.InvalidCastException: Specified cast is not valid." is generic and could be related to many things. I hope that the complete description from the event log will give me more information.

    Thanks,

    Jose

    Thursday, July 26, 2012 4:03 AM
  • Hello Jose,

    This exception comes in the console as a modal form.  The exception data is only what I've indicated at the beginning of this thread.  Clearing the exception allows operation to continue but when I get to the distribution list, it's empty.  Yet I know the relationships are there because otherwise I'd get hundreds of alerts for credentials not distributed. 

    I was running the console on a management server and was unable to locate a corresponding eventlog event in either the operations Manager, system, or application logs on the MS.

    I'm going to have to rebuild my list at this point.  My DBA's have been patiently standing by for some time now. 

    At best I can theorize that this was caused by one of the SQL Clusters we rebuilt (differently) without first removing the agentless and agent-based monitoring.

    Thanks for trying to help, Carl

    • Marked as answer by tx_cwf Thursday, July 26, 2012 3:14 PM
    Thursday, July 26, 2012 3:14 PM
  • If it's any consolation, I too had this issue. I have a SCOM 2012 CU1 environment (two of them actually) and one of them started up with the "Specified Cast is Invalid" error about two weeks ago. I ended up resolving it like this:

    1) exported a list of all discovered SQL Servers (to add back to the distribution tab)

    2) Renamed the SQL MP Run As Account to SQL MP Run As Account - BAD

    3) Created a new SQL MP Run As Account

    4) From within the SQL Server Discovery and SQL Server Monitoring account properties, I removed the BAD SQL MP Run As account and added the NEW SQL MP Run As account.  Ensure that you configure the NEW SQL MP RUN AS ACCOUNT to manage the SQL DB Engine Class!  This REMOVES the BAD SQL MP Profile from the Run As accounts and sets the NEW SQL MP Profile to be used by the Run As accounts.

    5) Once I re-distributed the credentials to my SQL Servers I remediated any stragglers and all was good.

    Wednesday, August 29, 2012 8:53 PM
  • I too saw this issue today, so renamed the account to old, created a new account, redistributed, reassociated the class to the profile, deleted the old account - all OK.

    I then saw it happen to another account later in the day (which I had checked earlier) and have now found what I think is the pattern...

    Earlier today, two agents were deleted from SCOM however these two agents would have been part of the Run As accounts distribution list.  This is also what happened to the original Run As account with the issue - some of the agents the account was distributed to were deleted from SCOM yesterday.

    So for this second occurrence of the issue, I Re-Approved the agent back into the Managment Group first (luckily it was still alive), then when I went back to the Distribution of the Run-As account, it was back to normal.

    The next step was to remove the agent from the Distribution, then delete the agent again from the Management Group.

    Rechecking the Run-As account after this order of procedings, the account remained healthy.

    Is this the cause?  It's not ideally the fix though, as we were lucky enough to know which agents to add back into the distribution list in this case.

    Cheers

    FYI - SCOM RTM environment.

    • Edited by Kiwifulla Thursday, May 30, 2013 2:23 AM
    • Proposed as answer by Kiwifulla Thursday, June 27, 2013 1:12 PM
    Wednesday, March 27, 2013 12:10 AM
  • I too saw this issue today, so renamed the account to old, created a new account, redistributed, reassociated the class to the profile, deleted the old account - all OK.

    I then saw it happen to another account later in the day (which I had checked earlier) and have now found what I think is the pattern...

    Earlier today, two agents were deleted from SCOM however these two agents would have been part of the Run As accounts distribution list.  This is also what happened to the original Run As account with the issue - some of the agents the account was distributed to were deleted from SCOM yesterday.

    So for this second occurrence of the issue, I simply readded the remaining account back into the distribution, and now the error has gone away.

    Is this the cause?  It's not ideally the fix though, as we were lucky enough to know which agents to add back into the distribution list in this case.

    Cheers

    How did you re-add the agents back into the distribution, if when you open the affected account, you get the "Specified Cast" error? When I get the error, I can click Close, and the account window opens, but with no agents listed in the distribution tab.

    If the agent was deleted, how did you add them back in?

    Wednesday, May 29, 2013 7:27 PM
  • I too saw this issue today, so renamed the account to old, created a new account, redistributed, reassociated the class to the profile, deleted the old account - all OK.

    I then saw it happen to another account later in the day (which I had checked earlier) and have now found what I think is the pattern...

    Earlier today, two agents were deleted from SCOM however these two agents would have been part of the Run As accounts distribution list.  This is also what happened to the original Run As account with the issue - some of the agents the account was distributed to were deleted from SCOM yesterday.

    So for this second occurrence of the issue, I simply readded the remaining account back into the distribution, and now the error has gone away.

    Is this the cause?  It's not ideally the fix though, as we were lucky enough to know which agents to add back into the distribution list in this case.

    Cheers

    How did you re-add the agents back into the distribution, if when you open the affected account, you get the "Specified Cast" error? When I get the error, I can click Close, and the account window opens, but with no agents listed in the distribution tab.

    If the agent was deleted, how did you add them back in?

    Sorry, I have worded that wrong (I will edit the original to reflect the correct order I did things in).

    I Re-Approved the agent back into the Managment Group first (luckily it was still alive), then when I went back to the Distribution of the Run-As account, it was back to normal.

    The next step was to remove the agent from the Distribution, then delete the agent again from the Management Group.

    Rechecking the Run-As account after this order of procedings, the account remained healthy.

    FYI - I am only on SCOM 2012 RTM, so hopefully this is fixed in SP1...

    Thursday, May 30, 2013 2:21 AM
  • FYI - we are now running OpsMgr 2012 SP1 UR3, and this problem still exists :(


    • Edited by Kiwifulla Tuesday, October 22, 2013 3:01 AM
    Tuesday, October 22, 2013 3:00 AM
  • Exactly same problem here. SCOM 2012 SP1.
    Thursday, November 21, 2013 4:23 PM
  • I just opened a case with Microsoft regarding this issue and they state this problem should have been fixed in UR2 or UR3.  I'm on SP1 UR4 and the problem is still there!

    Thursday, November 21, 2013 4:25 PM
  • I received this from Microsoft support:

    I have confirmed from the senior resources, that a bug has been filed for the same issue. The current workaround is to remove the sever from the distribution and then deleting it.

    So, maybe in UR5 or later, it will be fixed...

    This is frustrating...

    Thursday, November 21, 2013 5:47 PM
  • Hi,

    Just got this error with SCOM 2012 *R2* CU1.

    Regards

    Oliver

    Wednesday, February 19, 2014 12:29 PM
  • apparently, this problem is still not fixed. If it's happening in SCOM 2012 R2 CU1, this makes me believe it still exists in SCOM 2012 SP1 UR5 (NON R2).  I didn't see anything in the release notes for UR5. 

    Again, this is frustrating!

    Wednesday, February 19, 2014 1:09 PM
  • Can also confirm that this is still an issue with SCOM 2012 R2 CU1<o:p></o:p>

    And to solve it, reapply(reinstall) the agents on those servers
    that were removed and are on that list.

    This makes uninstalling agents even more annoying than it already is.
    Yet another thing need to check before removing agents.

    Cheers
    Lars Ivar


    Wednesday, May 7, 2014 9:22 AM
  • Ridiculous. I really wish this would get some attention and get fixed.

    On a side note, if you are heavily virtualized like we are, we typically uninstall the agent and shut down the VM and delete it.  Only to discover weeks later that someone deleted a SQL VM and forgot to remove it from the run as account. 

    To resolve, we will go through our change management logs of decommissioned servers and spin up some temporary servers with the exact same name, install the agent, go back into the run as account and properly remove the server from the run as account, uninstall the agent, and delete the vm.  It's a royal pain. But it does work.  At least, it has been for us. 

    maybe in Update Rollup 45, it'll get fixed :)

    Wednesday, May 7, 2014 11:35 PM
  • This is still occurring in SCOM 2012 R2 UR3.  I tested it specifically with a certain RunAs Profile/Account and when I deleted a specific object that I know was in the distribution, the entire distribution list was empty, after clicking OK past the "Specified cast is not valid" error.

    Sven

    Friday, October 3, 2014 11:56 AM
  • This will happen if an agent that was in distribution list for that account was removed from the management group. It is kind of silly but true. B. Wright answered it.

    link: https://social.technet.microsoft.com/Forums/systemcenter/en-US/854ecd97-acf6-48cc-828e-18f78989c7cc/runas-account-specified-cast-is-invalid

    Thursday, October 30, 2014 12:29 PM
  • This problem is apparently fixed in UR5 for 2012 R2!

    http://support.microsoft.com/kb/3023138

    RunAs accounts cannot be edited because of "Specified cast is invalid" exception

    RunAs accounts can be distributed only to a selected computer through the distribution tab of Run As Account properties. When a computer that is in the distribution list is decommissioned from Operations Manager and the Run As account is opened, you receive the following exception, and no computers are shown on the list:

    System.InvalidCastException: Specified cast is not valid.    at Microsoft.EnterpriseManagement.Monitoring.Internal.MonitoringObjectGenerated.get_Id()

    Has anyone verified that this UR fixes the issue?

    • Proposed as answer by Jure Labrovic Wednesday, February 11, 2015 4:31 AM
    • Marked as answer by tx_cwf Wednesday, February 11, 2015 3:38 PM
    Wednesday, February 11, 2015 4:00 AM
  • I can confirm that the issue has been resolved. Just installed UR5 in our testlab and wasn't able to reproduce the issue as I could before this update.
    Monday, February 16, 2015 2:54 PM