Dotfuscator and reflect methods

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi All,

I am a newbie to dotfuscator. I am trying to dotfuscate my application.
Everything seems ok except that when I try to run a method that has the
following command

poMsgObj.GetType()).GetMethod(psAfterMsg).Invoke(poMsgObj,new string []
{asSelectedValue};

I got an error saying "Object reference not set to an instance of an
object". I don't know what I can do in order to get the dotfuscated
application to work. Please help!!
 
The problem is that the obfuscation changes the names of types and methods (even
for reflection). The "psAfterMsg" probably contains the name of the method
before obfuscation and thus it doesn't match after obfuscation.

Here are some options:
1) Don't obfuscate methods that are used for reflection - I believe you can turn
off obfuscation for certain methods using the configuration files

2) Attach a custom attribute to the method that you can use to find it even if
its name gets obfuscated. Instead of GetMethod, you would search using the
custom attribute

Hope this helps.
 
How do you add the custom attribute?

Rodger Constandse said:
The problem is that the obfuscation changes the names of types and methods (even
for reflection). The "psAfterMsg" probably contains the name of the method
before obfuscation and thus it doesn't match after obfuscation.

Here are some options:
1) Don't obfuscate methods that are used for reflection - I believe you can turn
off obfuscation for certain methods using the configuration files

2) Attach a custom attribute to the method that you can use to find it even if
its name gets obfuscated. Instead of GetMethod, you would search using the
custom attribute

Hope this helps.

--
Rodger Constandse

<http://www.SequenceDiagramEditor.com>
Sequence Diagram Editor - A quick and easy way to draw and edit sequence diagrams

Alan said:
Hi All,

I am a newbie to dotfuscator. I am trying to dotfuscate my application.
Everything seems ok except that when I try to run a method that has the
following command

poMsgObj.GetType()).GetMethod(psAfterMsg).Invoke(poMsgObj,new string []
{asSelectedValue};

I got an error saying "Object reference not set to an instance of an
object". I don't know what I can do in order to get the dotfuscated
application to work. Please help!!
 
Also, I looked in some documents for dotfuscator, they mentioned that
dotfuscator will handle those renaming automatically. So does it mean it is
not really the case?

Thx

Rodger Constandse said:
The problem is that the obfuscation changes the names of types and methods (even
for reflection). The "psAfterMsg" probably contains the name of the method
before obfuscation and thus it doesn't match after obfuscation.

Here are some options:
1) Don't obfuscate methods that are used for reflection - I believe you can turn
off obfuscation for certain methods using the configuration files

2) Attach a custom attribute to the method that you can use to find it even if
its name gets obfuscated. Instead of GetMethod, you would search using the
custom attribute

Hope this helps.

--
Rodger Constandse

<http://www.SequenceDiagramEditor.com>
Sequence Diagram Editor - A quick and easy way to draw and edit sequence diagrams

Alan said:
Hi All,

I am a newbie to dotfuscator. I am trying to dotfuscate my application.
Everything seems ok except that when I try to run a method that has the
following command

poMsgObj.GetType()).GetMethod(psAfterMsg).Invoke(poMsgObj,new string []
{asSelectedValue};

I got an error saying "Object reference not set to an instance of an
object". I don't know what I can do in order to get the dotfuscated
application to work. Please help!!
 
Back
Top