Red Gate forums :: View topic - Problem while obfuscation of silverlight .xap
Return to www.red-gate.com RSS Feed Available

Search  | Usergroups |  Profile |  Messages |  Log in  Register 
Go to product documentation
SmartAssembly 6
SmartAssembly 6 forum

Problem while obfuscation of silverlight .xap

Search in SmartAssembly 6 forum
Post new topic   Reply to topic
Jump to:  
Author Message
anand.mohan



Joined: 19 Jul 2013
Posts: 5
Location: India

PostPosted: Fri Jul 19, 2013 8:29 am    Post subject: Problem while obfuscation of silverlight .xap Reply with quote

Hi,

I have some issues regarding obfuscating silverlight .xap.
actually in my project there are few third party dlls have been used, so when i am trying to obfuscate my project's xap then after obfuscation when i am hosting it gets blank.
While doing workaround for it I made the replica of that project and when i had excluded the user-control in which the T-Chart dll had been used then its working fine. But here is some more problem that in my project there are some modules in which there is some code parts and also it consists of TChart's dll.
For this I had go through some topics present on the forum where i found that using Custom Attributes we can exclude that code which we don't want to obfuscate but the problem remains same.
Plz. help in this matter.
_________________
Anand Mohan
Back to top
View user's profile Send private message
anand.mohan



Joined: 19 Jul 2013
Posts: 5
Location: India

PostPosted: Mon Jul 22, 2013 8:36 am    Post subject: reply its urgent.... Reply with quote

hello sir,
please reply me as soon as possible its very urgent...



Thanks:
_________________
Anand Mohan
Back to top
View user's profile Send private message
jessica.ramos



Joined: 23 Apr 2012
Posts: 213

PostPosted: Mon Jul 22, 2013 6:21 pm    Post subject: Reply with quote

Hi Anand, many thanks for your post.

Could you kindly try turning on error reporting to see if you can get more details about what parts of code might need to be excluded?

Also can you please check--if you run your application through SmartAssembly with all features turned off, does your application still crash/throw errors?
_________________
Jessica Ramos
Technical Support
Red Gate Software Ltd.
Back to top
View user's profile Send private message
anand.mohan



Joined: 19 Jul 2013
Posts: 5
Location: India

PostPosted: Tue Jul 23, 2013 8:46 am    Post subject: Reply with quote

Thanks Jessica for replying me. I got error message after turning on the error reporting. This message comes when i try to open the child-window the message is as belo-
" Failed to assign to property 'System.Windows.Controls.Primitives.ButtonBase.Click'. "
My application is running fine if i run my application through SmartAssembly with all features turned off.
I had excluded some of the Namespaces which contained third party dll after that i got success in running my application but now the problem is that the child-windows are not getting popped-up and one of my application's page which reads an .xml file using WCF.RIA services, is not getting executed.


Thanks & Regards:
_________________
Anand Mohan
Back to top
View user's profile Send private message
jessica.ramos



Joined: 23 Apr 2012
Posts: 213

PostPosted: Tue Jul 23, 2013 11:52 pm    Post subject: Reply with quote

I'm glad to hear you've got a bit further after adding some exclusions!

One thing to make sure of: is every member called on by reflection from your XAML files excluded from obfuscation? SmartAssembly will automatically exclude some things from obfuscation to make sure your xaml file still works with your application, but sometimes you may need to manually exclude anything it missed.

Pruning might also be an issue (if so, you can use the DoNotPrune attribute to exclude any types in question from pruning ). Are you using this feature by any chance?

Also, just to confirm, did those exclusions you added resolve the "failed to assign to property" error? If not, it sounds like there is an event handler that you'll need to exclude from obfuscation (http://stackoverflow.com/questions/5482872/usercontrol-inheritance-problem-in-silverlight)
_________________
Jessica Ramos
Technical Support
Red Gate Software Ltd.
Back to top
View user's profile Send private message
anand.mohan



Joined: 19 Jul 2013
Posts: 5
Location: India

PostPosted: Wed Jul 24, 2013 11:13 am    Post subject: Reply with quote

Hi Jessica, below is my sample project code in this i had added a hyperlink button and a button & on the click of it i am trying to open a child window.
It is running fine without obfuscation but after obfuscation its not getting popped-up. Please look into this,

Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace Child_Window
{
    public partial class MainPage : UserControl
    {
        public MainPage()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {       
            demo objdemo = new demo();
            objdemo.Show();
        }

        private void hyperlinkButton1_Click(object sender, RoutedEventArgs e)
        {
            demo objdemo = new demo();
            objdemo.Show();
        }
    }
}


XAML,

Code:
<UserControl x:Class="Child_Window.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400">

    <Grid x:Name="LayoutRoot" Background="White">
        <HyperlinkButton Content="Click to Open Smart Assembly" Height="23" HorizontalAlignment="Left" Margin="108,79,0,0" Name="hyperlinkButton1" VerticalAlignment="Top" Width="175" Click="hyperlinkButton1_Click" />
        <Button Content="Click to Open Smart Assembly" Height="23" HorizontalAlignment="Left" Margin="92,147,0,0" Name="button1" VerticalAlignment="Top" Width="191" Click="button1_Click" />
    </Grid>
</UserControl>



Thanks & Regards:
_________________
Anand Mohan
Back to top
View user's profile Send private message
jessica.ramos



Joined: 23 Apr 2012
Posts: 213

PostPosted: Wed Jul 24, 2013 8:00 pm    Post subject: Reply with quote

Many thanks for the sample project! Can you please try excluding the event handlers "hyperlinkButton1_Click" and "button1_Click" from being obfuscated?

When they are obfuscated, they no longer can be found by the original names they are referenced by in the XAML. This is what causes the "failed to assign to property" error.

You can either add the exclusion from the SmartAssembly UI or by using the custom attributes - http://www.red-gate.com/supportcenter/content/SmartAssembly/help/6.7/SA_UsingCustomAttributes

I hope that helps! Please give it a try and let me know if there are any further issues.
_________________
Jessica Ramos
Technical Support
Red Gate Software Ltd.
Back to top
View user's profile Send private message
anand.mohan



Joined: 19 Jul 2013
Posts: 5
Location: India

PostPosted: Thu Jul 25, 2013 2:01 pm    Post subject: Reply with quote

Thanks a lot Jessica,
It worked for me, now my application is running fine after obfuscating the xap. But still there is an issue present that when i am reflecting the obfuscated xap then the variables & fields are still present with their real names.
Plz. look into this so that i will be able to fully obfuscate my xap which will increase its reliability in terms of code protection.


Thanks & Regards:
_________________
Anand Mohan
Back to top
View user's profile Send private message
jessica.ramos



Joined: 23 Apr 2012
Posts: 213

PostPosted: Fri Jul 26, 2013 6:18 pm    Post subject: Reply with quote

I'm glad to hear that got the application working! I think I may be working with one of your colleagues who mentioned the same issue with the names.. I explained to him that SmartAssembly automatically excludes some code if it determines that obfuscation might cause your application not to work, or if a string might be displayed in the user interface.

The following types are always excluded from obfuscation to ensure that your application works correctly:
-Public members of DLLs
-Types with the Serializable attribute.
-Types with a base class of System.MulticastDelegate.
-Types with System.ServiceModel.OperationContractAttribute specified.
-Types with System.ServiceModel.ServiceContractAttribute specified.
-Types with any attribute starting System.Xml.Serialization.
-Methods with System.Reflection.DefaultMemberAttribute specified.

Also..
-Enums are normally obfuscated, but SmartAssembly assumes that enum values which have Format, GetName, GetNames, Parse, or ToString called on them will be displayed to users. These enums are therefore excluded from obfuscation automatically.
-If a member name is the same in one more than one class, the member names might not be renamed. To ensure that they are renamed, under Obfuscation, select the Advanced renaming fields name mangling option.
(Note that selecting Advanced renaming prevents Decode Stack Trace from retrieving the names of the original fields.)

To see why SmartAssembly has not obfuscated your code, you can create a log file in 'TRACE' mode. For more information, see Log file for SmartAssembly.

Hope this information helps!
_________________
Jessica Ramos
Technical Support
Red Gate Software Ltd.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic All times are GMT + 1 Hour
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group