Detected malicious verification code error


Detected malicious verification code when verifying element of type Microsoft.EnterpriseManagement.Configuration.ManagementPackRule with inner exception: System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary

When building a management pack in Visual Studio you may run into this very ambiguous error shown below.

Severity	Code	Description	Project	File	Line	Suppression State
Error		Detected malicious verification code when verifying element of type Microsoft.EnterpriseManagement.Configuration.ManagementPackRule with inner exception: System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
   at System.ThrowHelper.ThrowKeyNotFoundException()
   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
   at Microsoft.EnterpriseManagement.Configuration.ManagementPackRule.VerifyDataTypes(Dictionary`2 moduletypes)
   at Microsoft.EnterpriseManagement.Configuration.ManagementPackRule.Verify(VerificationContext context)
   at Microsoft.EnterpriseManagement.Configuration.Verification.VerificationEngine.VerifyCollectionItems(Object context)   (Path = ServiceConnector)	ServiceConnector	C:\Program Files (x86)\MSBuild\Microsoft\VSAC\Microsoft.SystemCenter.OperationsManager.targets	317	

This can happen for a number of reasons

  1. Misspelled variable (incorrect formatting or missing dollar sign ($)).
    Params/Param[5] instead of $Data/Params/Param[5]$ or vica versa.
    $Data/Property[@Name=’DirectoryPercentConsumed’]$ instead of Property[@Name=’DirectoryPercentConsumed’] or vica versa.
    $Target/Property[Type=”M365SL.WatcherNode”]/TenantName is missing the trailing ‘$’. It should be like this:
    $Target/Property[Type=”M365SL.WatcherNode”]/TenantName$
  2. Accessibility (Internal vs Public) might be incorrect as documented by Michel Kamp here.
  3. In my case, I was writing a performance rule and I accidentally misspelled one of my Write Actions. (I was supposed to have one for writing to the OpsDB and one for writing to the DW.) I copy/pasted the WriteAction name without the alias reference.


Summary

I should have used the picker to eliminate potential for errors.

Leave a Reply

Your email address will not be published. Required fields are marked *