Home - Forums-.NET - Spices.Net - Report sharp shootwe error after obfuscated

Spices.Net

NET code security, tools to protect, obfuscate, tamper defense, code and data safety, recover, convert, optimize, explore, browse and analyze .Net software.

This forum related to following products: Spices.Net Suite, Spices.Net Obfuscator, Spices.Net Decompiler

Report sharp shootwe error after obfuscated
Link Posted: 09-Oct-2005 19:43
I have the following code in my application:



rptDesigner1.DataSourceManager = reportGenerator1.DataSources;

rptDesigner1.Document = reportGenerator1.Template;



The program executed well until I obfuscated using Spices.Obfuscator.

The error was:



“The current thread must set to Single Thread Apartment (STA) mode before OLE calls can be made.  Ensure that your Main function has STAThreadAttribute marked on it.”



The error thrown when reaches the second statement.

I have the STA mode on my main form.



Please help me ASAP.
Link Posted: 10-Oct-2005 04:49
Please provide me with more details:
1. Do you obfuscate your app without including RSS into obfuscation?
2. What obfuscation mode (ObfuscationOptions.Member) do you using?
Link Posted: 10-Oct-2005 15:25
[quote="NineRays"]Please provide me with more details:
1. Do you obfuscate your app without including RSS into obfuscation?
2. What obfuscation mode (ObfuscationOptions.Member) do you using?


1. No, I am not include RSS into obfuscation.
2. I have three layer in my application:

Main.exe -- obfuscation mode full
BusinessLogic.dll -- obfuscation mode default improved
DataAccess.dll -- obfuscation mode default improved

Security.dll -- obfuscation mode full

All PE file depend on Security.dll that implement software copy protection.
Main.exe depend on BusinessLogic.dll
BusinessLogic depend on DataAccess.dll

I create report editor form using rptDesigner controls and other RSS supporting controls. I pass the reportGenerator object that created in another form that enable user to select the template to the report editor form. The template are loaded using LoadTemplate method of reportGenerator.

Both report editor form and template selection form are dialog of the MainForm.

Thank you.
Link Posted: 10-Oct-2005 19:26
Try to set reportGenerator1.OwnerForm to the your main form.
Link Posted: 11-Oct-2005 15:10
I have my problems solved using another solution. Anyway, thank you for your help.

My solution is:
I add two messagebox to monitor the CurrentThread.ApartmentState of my application.

[STAThread]
static public void Main()
{
    MessageBox.Show(Thread.CurrentThread.ApartmentState.ToString());
    Application.Run(new MainForm());
}

private void MainForm_Load(object sender, System.EventArgs e)
{
    MessageBox.Show(Thread.CurrentThread.ApartmentState.ToString());
    ...
}


Before obfuscation, both messagebox display STA for the ApartmentState value. Amazingly, after obfuscation the first messagebox display Unknown, and the second one display MTA. I wonder why this can happen, I allready add the [STAThread] attribute to the main function.

Finally I force the ApartmentState to STA


[STAThread]
static public void Main()
{
    Thread.CurrentThread.ApartmentState = ApartmentState.STA;
    MessageBox.Show(Thread.CurrentThread.ApartmentState.ToString());
    Application.Run(new MainForm());
}


Both messagebox display STA before and after obfuscation and my problem is solved.

Do you have any explanation about this?

Thank you very much.
Link Posted: 12-Oct-2005 08:29
Do you have any explanation about this?

It seem that the AppartmentState of current thread was not defined,
please check existance of [STAThread] attribute attached to the main procedure of your obfuscated app.