Dotfuscator and reflect methods

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!!
 
R

Rodger Constandse

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.
 
G

Guest

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!!
 
G

Guest

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!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top