SmartAssembly Bug - Enum.TryParse - .NET 4.0 Issue -
mltgames
Posts: 17 Bronze 1
I have a big issue with Smart Assembly 6.8.0.121...
I have visual studio 2013 with update 3 and it's a C# .NET 4.0 project.
I solved the issue by removing the offuscation but this is a bad idea if we want our project secure. So i found a workaround...
The issue is with only Enum.TryParse... (This feature is new Inside .NET 4.0) and if you don't have any ToString() to a value Inside the enum. (Take note that Enum.Parse is working)
Here is my code
//////////////////////////////////////
// Result type.
//////////////////////////////////////
public enum eResult_Field
{
RESULT, // Si ça fonctionner. SUCCESS= approuvé
ACCOUNT, // # de carte
ACCOUNTTYPE, // TYPE DE CARTE
APPROVEDAMOUNT, // Montant approuver
APPROVALCODE, // Code d'approbation
TIPAMOUNT, // Quantité de tip
EXPIRATION, // Expiration de la carte.
RECEIPT, // Si on a un recu.
DESCRIPTION // Message
};
//////////////////////////////////////
// Check error fct
//////////////////////////////////////
public override string Check_Error()
{
eResult_Field eNode;
string sError = "";
if (Enum.TryParse("DESCRIPTION", true, out eNode)) <
This fonction return false even if i entered "DESCRIPTION" !
{
switch (eNode)
{
case eResult_Field.DESCRIPTION:
sError = "MY BIG ERROR";
break;
}
}
return sError;
}
When i execute this code it should find the enum DESCRIPTION and return true but it's not!
I also found something to fix the issue. (I also tried parse instead of try parse and it work.)
If by example, i add to my project
// PATCH FOR OFFUSCATION.
static string DeofucationTemp = eResult_Field.RESULT.ToString();
The first call ToString() to whatever enum value Inside it fix the issue.
Now if I execute the same fonction Check_Error() it return true and I get my error "MY BIG ERROR" instead of an empty string.
It look like the offuscator change the name Inside the enum but it make TryParse to do not work and do not reconize my string DESCRIPTION. But why it work with Parse? This is really strange.
I don't know why it's only TryParse having this issue but i think this issue should be solved because it can create alot of strange problem if people are using Enum.TryParse Inside their project.
I have visual studio 2013 with update 3 and it's a C# .NET 4.0 project.
I solved the issue by removing the offuscation but this is a bad idea if we want our project secure. So i found a workaround...
The issue is with only Enum.TryParse... (This feature is new Inside .NET 4.0) and if you don't have any ToString() to a value Inside the enum. (Take note that Enum.Parse is working)
Here is my code
//////////////////////////////////////
// Result type.
//////////////////////////////////////
public enum eResult_Field
{
RESULT, // Si ça fonctionner. SUCCESS= approuvé
ACCOUNT, // # de carte
ACCOUNTTYPE, // TYPE DE CARTE
APPROVEDAMOUNT, // Montant approuver
APPROVALCODE, // Code d'approbation
TIPAMOUNT, // Quantité de tip
EXPIRATION, // Expiration de la carte.
RECEIPT, // Si on a un recu.
DESCRIPTION // Message
};
//////////////////////////////////////
// Check error fct
//////////////////////////////////////
public override string Check_Error()
{
eResult_Field eNode;
string sError = "";
if (Enum.TryParse("DESCRIPTION", true, out eNode)) <
This fonction return false even if i entered "DESCRIPTION" !
{
switch (eNode)
{
case eResult_Field.DESCRIPTION:
sError = "MY BIG ERROR";
break;
}
}
return sError;
}
When i execute this code it should find the enum DESCRIPTION and return true but it's not!
I also found something to fix the issue. (I also tried parse instead of try parse and it work.)
If by example, i add to my project
// PATCH FOR OFFUSCATION.
static string DeofucationTemp = eResult_Field.RESULT.ToString();
The first call ToString() to whatever enum value Inside it fix the issue.
Now if I execute the same fonction Check_Error() it return true and I get my error "MY BIG ERROR" instead of an empty string.
It look like the offuscator change the name Inside the enum but it make TryParse to do not work and do not reconize my string DESCRIPTION. But why it work with Parse? This is really strange.
I don't know why it's only TryParse having this issue but i think this issue should be solved because it can create alot of strange problem if people are using Enum.TryParse Inside their project.