0

The problem i am facing is...during the installation of my WMI application (which has obfuscated dlls) below error is shown: Incorrect usage of [ManagementBind] attribute on a method. 'a' on class 'ak' (ak, Myapp.MyProvider, Version=1.3.0.11, Culture=neutral, PublicKeyToken=213fdfdfdf32dfef) definition. It should be on a static method and there should be one matching parameter for every key defined. "

Please let me know how to resolve this error.

Mukul Kashmira
  • 199
  • 1
  • 7

1 Answers1

0

It does not sounds logical to obfuscate everything in your WMI provider. Since the metadata (like the names of methods, parameters and classes) describes how your WMI provider looks at the outside. Do you want the users your WMI provider to have a WMI class named ak? And a WMI method named a? I would rather have a MySomethingProvider with a GetInstances method.

But even if you want your users having to deal with obfuscated names, I think this obfuscation does not go well with how the metadata of a Managed WMI Provider should look.

For example, here the ManagementName attribute points to ID, but I bet that obfuscating it will have given ID another name. That is why they don't match

[ManagementBind]
static public WIN32ServiceHost GetInstance([ManagementName("ID")] int processId)
{
}

[ManagementKey]
public int ID

After obfuscation string in ManagementName is still ID, but now the property ID is called A.

[ManagementBind]
static public WIN32ServiceHost a([ManagementName("ID")] int a)
{
}

[ManagementKey]
public int A

So either don't obfuscate at all or only the parts that are not public or are part of your WMI API.

Lars Truijens
  • 42,837
  • 6
  • 126
  • 143
  • Thanks it really helped. One more question i would like to ask...that is...if i am using Reflection in my code..for ex GetType() etc methods then should i use exclude whole class of corrosponding type from obfuscation or should i just exclude data members and properties. will the member function would cause issue in this case after obfuscation? – Mukul Kashmira Jun 05 '14 at 05:09
  • To be more precise...Should i exclude only public members/properties/methods from obfuscation and should obfuscate private member/methods/properties of obfuscated class ? – Mukul Kashmira Jun 05 '14 at 06:52
  • IMHO obfuscation is hardly of any use, but you should exclude everything that is used in reflection and everything others outside of your assembly/product use. That last usually means public yes. But if you understand the problem you can figure it out for yourself. – Lars Truijens Jun 05 '14 at 07:17
  • yes..thanks for suggestion. I excluded verything related to reflection and WMI classes(which were supposed to get referenced from outside) and i my app is working fine. – Mukul Kashmira Jun 12 '14 at 08:20