Removing PoweredByAttribute

EatonEaton Posts: 19
edited July 21, 2010 12:25PM in SmartAssembly 5
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.

Comments

  • Paul.MartinPaul.Martin Posts: 83 New member
    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).
  • 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?
    <Options>
            <DoNotAddPoweredByAttribute />
            <WebProxy UseProxy="0" />
            <Projects UseRelativePaths="1" />
        </Options>
    
    Because that is not working.

    Also, why is it not recommended to do that?
  • Paul.MartinPaul.Martin Posts: 83 New member
    Sorry, my fault, I meant to say the SmartAssembly project file (*.saproj or *.{sa}proj).
  • 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 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.
  • Paul.MartinPaul.Martin Posts: 83 New member
    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.
  • 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
  • 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.
  • Paul.MartinPaul.Martin Posts: 83 New member
    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?
  • 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.
  • Paul.MartinPaul.Martin Posts: 83 New member
    Eaton, I've sent you a 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.
  • Paul.MartinPaul.Martin Posts: 83 New member
    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
    DevExpress.XtraEditors.BaseListBoxControl.add_SelectedIndexChanged&#40; System.EventHandler &#41;
    
    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.
  • I'm glad you were able to find and fix the problem! Looking forward to a fix version. :)
  • Funny thing is, I'm also referencing DevExpress in my program. I've managed to get SmartAssembly working by building against .Net 3.5.

    Glad you guys found out what was happening. Looking forward to the next release.
  • Paul.MartinPaul.Martin Posts: 83 New member
    Just to keep you updated guys this bug is firmly listed to be fixed in the next update. I don't have a release date yet, I'll pester the developers to find out when the release date will be and if I can get an earlier copy.
Sign In or Register to comment.