Removing PoweredByAttribute

.NET obfuscator and automated error reporting

Moderators: Luke Jefferson, Alex.Davies, melvyn.harbour

Removing PoweredByAttribute

Postby Eaton » Tue Jun 22, 2010 5:12 am

How do I prevent this from being added to my assembly? A third party component I use usually reports the file version, but for some reason, it reports the version of SA that was used to protect my assembly... So I open my exe in a hex editor and do a search for the string.

It found an instance: http://img571.imageshack.us/img571/1732/pbafrg.png

When I modify that string, it the 3rd party component reflects the change! I would just edit it there, but sadly, my version is one byte longer and adding that will break the application.

Please tell me how to remove the attribute.
Eaton
 
Posts: 16
Joined: Tue May 18, 2010 4:20 am

Postby Paul.Martin » Tue Jun 22, 2010 11:53 am

We don't recommend it, because it breaks error reporting, but...
Add a node called "DoNotAddPoweredByAttribute" in the "Options" section of the SmartAssembly.settings file.

However, you should really log a bug with the third party component as it is picking up the version number of a reference assembly, which is just wrong (it may as well just always return 2.0.0.0 - which could be the version of the .NET Framework core libraries).
Paul.Martin
 
Posts: 83
Joined: Wed Feb 03, 2010 11:20 am
Location: Cambridgeshire

Postby Eaton » Tue Jun 22, 2010 3:12 pm

I already did, but I do not expect much from them as they usually fix bugs they find and not the ones that people report.

Also, I can't get your workaround to work. Is this correct?
Code: Select all
    <Options>
        <DoNotAddPoweredByAttribute />
        <WebProxy UseProxy="0" />
        <Projects UseRelativePaths="1" />
    </Options>

Because that is not working.

Also, why is it not recommended to do that?
Eaton
 
Posts: 16
Joined: Tue May 18, 2010 4:20 am

Postby Paul.Martin » Tue Jun 22, 2010 3:57 pm

Sorry, my fault, I meant to say the SmartAssembly project file (*.saproj or *.{sa}proj).
Paul.Martin
 
Posts: 83
Joined: Wed Feb 03, 2010 11:20 am
Location: Cambridgeshire

Postby Eaton » Tue Jun 22, 2010 5:06 pm

Ok, thanks, I added it, but now I get get a build error:
http://img641.imageshack.us/img641/5119/errorgj.png

I backed up my old project file so I tried that and I still got the error. So I am guessing it is a recent change in my application that is causing this.

However, in the EAP forum, which doesn't appear to be here anymore, I recall someone having this error. He had two versions of mscorlib referenced. I open my application in Reflector and I have two referenced! .NET 2 and 4.

Any idea on how to remove that reference? It isn't in the References in the project itself in VS.
Eaton
 
Posts: 16
Joined: Tue May 18, 2010 4:20 am

Re:

Postby craigm » Wed Jun 23, 2010 1:20 pm

Eaton wrote:Ok, thanks, I added it, but now I get get a build error:
http://img641.imageshack.us/img641/5119/errorgj.png

I backed up my old project file so I tried that and I still got the error. So I am guessing it is a recent change in my application that is causing this.

However, in the EAP forum, which doesn't appear to be here anymore, I recall someone having this error. He had two versions of mscorlib referenced. I open my application in Reflector and I have two referenced! .NET 2 and 4.

Any idea on how to remove that reference? It isn't in the References in the project itself in VS.


I'm also getting a similar error. Reflector also shows that mscorlib is referenced twice for version 4.0 and 2.0. Depending on which settings I choose in SmartAssembly, I can get the error to refer to either System.Tuple, Action(T1, T2) or Func<T, TResult>, etc. It always seems to be a construct that has been introduced since .Net 2.0. This makes me think that SmartAssembly is getting confused as to which version of .net it is meant to be building against. Haven't worked out a way of getting it to work yet.
craigm
 
Posts: 9
Joined: Wed Jun 23, 2010 1:13 pm

Postby Paul.Martin » Wed Jun 23, 2010 1:36 pm

Could you have look at your original (before SmartAssembly protected) assembly in Reflector and see if it is referencing two version of mscorlib.

SmartAssembly should look at the version of mscorlib referenced and from that and a few other hints link against the correct version of the framework.
Paul.Martin
 
Posts: 83
Joined: Wed Feb 03, 2010 11:20 am
Location: Cambridgeshire

Postby craigm » Wed Jun 23, 2010 1:39 pm

Yes, it is referencing mscorlib twice.


// Assembly Reference mscorlib
Version: 2.0.0.0
Name: mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089


// Assembly Reference mscorlib
Version: 4.0.0.0
Name: mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
craigm
 
Posts: 9
Joined: Wed Jun 23, 2010 1:13 pm

Re:

Postby Eaton » Wed Jun 23, 2010 3:41 pm

Paul.Martin wrote:Could you have look at your original (before SmartAssembly protected) assembly in Reflector and see if it is referencing two version of mscorlib.

SmartAssembly should look at the version of mscorlib referenced and from that and a few other hints link against the correct version of the framework.


That is what I am doing, I open my unprotected assembly in Reflector and there are two references. I can't look at a protected version because it gives me a build error every time.
Eaton
 
Posts: 16
Joined: Tue May 18, 2010 4:20 am

Re:

Postby Paul.Martin » Wed Jun 23, 2010 7:00 pm

Eaton wrote:I can't look at a protected version because it gives me a build error every time.


Sorry yes.


OK, well that narrows down the problem slightly. If you have a look in the *.csproj (or *.vbproj) in notepad or similar does it mention both versions of mscorlib?
Paul.Martin
 
Posts: 83
Joined: Wed Feb 03, 2010 11:20 am
Location: Cambridgeshire

Re:

Postby Eaton » Wed Jun 23, 2010 7:03 pm

Paul.Martin wrote:
Eaton wrote:I can't look at a protected version because it gives me a build error every time.


Sorry yes.


OK, well that narrows down the problem slightly. If you have a look in the *.csproj (or *.vbproj) in notepad or similar does it mention both versions of mscorlib?


I have done some very intensive research on this matter. I have checked my project file for references to mscorlib, but none exist. All of the other references are there, but none to mscorlib at all.

I then proceeded to start a new project and put all of my classes and forms into it. Still the same issue.
Eaton
 
Posts: 16
Joined: Tue May 18, 2010 4:20 am

Postby Paul.Martin » Wed Jun 23, 2010 7:15 pm

Eaton, I've sent you a PM.
Paul.Martin
 
Posts: 83
Joined: Wed Feb 03, 2010 11:20 am
Location: Cambridgeshire

Postby Eaton » Wed Jun 23, 2010 9:21 pm

I have provided a sample project. Hopefully you guys can use it to pinpoint the problem.

Let me know if you need anything else. I am more than happy to help you make SmartAssembly a better product.
Eaton
 
Posts: 16
Joined: Tue May 18, 2010 4:20 am

Postby Paul.Martin » Thu Jun 24, 2010 6:23 pm

Having spent a while digging in the IL code and talking with our development team, I think we have worked out why it is adding multiple version references.

If you pass a non-primitive core framework object to a method in a reference assembly which depends on a different version of the .NET framework then it will automatically add a reference to this different version.

For instance in the code you sent Eaton, there was a call to
Code: Select all
DevExpress.XtraEditors.BaseListBoxControl.add_SelectedIndexChanged( System.EventHandler )

because the DevExpress dll was linked against the CLR 2.0 the System.EventHandler that had to be passed was the one in mscorlib 2.0 rather than the one in mscorlib 4.0 (which to the .NET framework is completely different although implicitly cast-able), so the reference was automatically added.


The developers will fix SmartAssembly so that it copes with this situation, now we know what the problem is.


Thank you very much for all your help.
Paul.Martin
 
Posts: 83
Joined: Wed Feb 03, 2010 11:20 am
Location: Cambridgeshire

Postby Eaton » Thu Jun 24, 2010 7:48 pm

I'm glad you were able to find and fix the problem! Looking forward to a fix version. :)
Eaton
 
Posts: 16
Joined: Tue May 18, 2010 4:20 am

Next

Return to SmartAssembly 5

Who is online

Users browsing this forum: No registered users and 0 guests