Red Gate forums :: View topic - Removing PoweredByAttribute
Return to www.red-gate.com RSS Feed Available

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

Removing PoweredByAttribute

Search in SmartAssembly 5 forum
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.
Jump to:  
Go to page 1, 2  Next
Author Message
Eaton



Joined: 18 May 2010
Posts: 16

PostPosted: Tue Jun 22, 2010 5:12 am    Post subject: Removing PoweredByAttribute Reply with quote

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.
Back to top
View user's profile Send private message AIM Address
Paul.Martin



Joined: 03 Feb 2010
Posts: 83
Location: Cambridgeshire

PostPosted: Tue Jun 22, 2010 11:53 am    Post subject: Reply with quote

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).
Back to top
View user's profile Send private message
Eaton



Joined: 18 May 2010
Posts: 16

PostPosted: Tue Jun 22, 2010 3:12 pm    Post subject: Reply with quote

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:
    <Options>
        <DoNotAddPoweredByAttribute />
        <WebProxy UseProxy="0" />
        <Projects UseRelativePaths="1" />
    </Options>

Because that is not working.

Also, why is it not recommended to do that?
Back to top
View user's profile Send private message AIM Address
Paul.Martin



Joined: 03 Feb 2010
Posts: 83
Location: Cambridgeshire

PostPosted: Tue Jun 22, 2010 3:57 pm    Post subject: Reply with quote

Sorry, my fault, I meant to say the SmartAssembly project file (*.saproj or *.{sa}proj).
Back to top
View user's profile Send private message
Eaton



Joined: 18 May 2010
Posts: 16

PostPosted: Tue Jun 22, 2010 5:06 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message AIM Address
craigm



Joined: 23 Jun 2010
Posts: 9

PostPosted: Wed Jun 23, 2010 1:20 pm    Post subject: Re: Reply with quote

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.
Back to top
View user's profile Send private message
Paul.Martin



Joined: 03 Feb 2010
Posts: 83
Location: Cambridgeshire

PostPosted: Wed Jun 23, 2010 1:36 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
craigm



Joined: 23 Jun 2010
Posts: 9

PostPosted: Wed Jun 23, 2010 1:39 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
Eaton



Joined: 18 May 2010
Posts: 16

PostPosted: Wed Jun 23, 2010 3:41 pm    Post subject: Re: Reply with quote

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.
Back to top
View user's profile Send private message AIM Address
Paul.Martin



Joined: 03 Feb 2010
Posts: 83
Location: Cambridgeshire

PostPosted: Wed Jun 23, 2010 7:00 pm    Post subject: Re: Reply with quote

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?
Back to top
View user's profile Send private message
Eaton



Joined: 18 May 2010
Posts: 16

PostPosted: Wed Jun 23, 2010 7:03 pm    Post subject: Re: Reply with quote

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.
Back to top
View user's profile Send private message AIM Address
Paul.Martin



Joined: 03 Feb 2010
Posts: 83
Location: Cambridgeshire

PostPosted: Wed Jun 23, 2010 7:15 pm    Post subject: Reply with quote

Eaton, I've sent you a PM.
Back to top
View user's profile Send private message
Eaton



Joined: 18 May 2010
Posts: 16

PostPosted: Wed Jun 23, 2010 9:21 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message AIM Address
Paul.Martin



Joined: 03 Feb 2010
Posts: 83
Location: Cambridgeshire

PostPosted: Thu Jun 24, 2010 6:23 pm    Post subject: Reply with quote

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:
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.
Back to top
View user's profile Send private message
Eaton



Joined: 18 May 2010
Posts: 16

PostPosted: Thu Jun 24, 2010 7:48 pm    Post subject: Reply with quote

I'm glad you were able to find and fix the problem! Looking forward to a fix version. Smile
Back to top
View user's profile Send private message AIM Address
Display posts from previous:   
This topic is locked: you cannot edit posts or make replies. All times are GMT + 1 Hour
Go to page 1, 2  Next
Page 1 of 2

 
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