By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,376 Members | 1,566 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,376 IT Pros & Developers. It's quick & easy.

Dotfuscator and reflect methods

P: n/a
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(p oMsgObj,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!!
Nov 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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 Mok wrote:
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(p oMsgObj,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!!

Nov 17 '05 #2

P: n/a
How do you add the custom attribute?

"Rodger Constandse" wrote:
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 Mok wrote:
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(p oMsgObj,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!!

Nov 17 '05 #3

P: n/a
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" wrote:
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 Mok wrote:
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(p oMsgObj,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!!

Nov 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.