Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Programatically removing a reference???

Programatically removing a reference???

Scheduled Pinned Locked Moved C#
csharphelpquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Christopher Stratmann
    wrote on last edited by
    #1

    I have some custom controls which contains a System.Windows.Forms.Label control. I would like to be able to swap out those label controls with a third party label control. What I would like to do is the following... #if UsingThirdPartyControls namespace WindowsApplication4 { public class MyCustomLabel : ThirdPartyLabel { } } #else namespace WindowsApplication4 { public class MyCustomLabel : Label { } } #endif Now I can use MyCustomLabel in my custom controls and based on the type of build (one build will have UsingThirdPartyControls defined and another will not). The problem is removing the reference to the third party controls. Is there a way I can programatically tell the C# compiler to remove the references to the third party assemblies. That way when I deploy my custom control the third party assemblies are not deployed because they are not required? Chris

    V 1 Reply Last reply
    0
    • C Christopher Stratmann

      I have some custom controls which contains a System.Windows.Forms.Label control. I would like to be able to swap out those label controls with a third party label control. What I would like to do is the following... #if UsingThirdPartyControls namespace WindowsApplication4 { public class MyCustomLabel : ThirdPartyLabel { } } #else namespace WindowsApplication4 { public class MyCustomLabel : Label { } } #endif Now I can use MyCustomLabel in my custom controls and based on the type of build (one build will have UsingThirdPartyControls defined and another will not). The problem is removing the reference to the third party controls. Is there a way I can programatically tell the C# compiler to remove the references to the third party assemblies. That way when I deploy my custom control the third party assemblies are not deployed because they are not required? Chris

      V Offline
      V Offline
      vytheese
      wrote on last edited by
      #2

      I never tried, but as of my understanding, The Solution file ( *.csProj ) contains the sections to add reference under ItemGroup tag these references are listed. This tag supports condition attribute. So you can write a custom task, which executes under target BeforeCoreGet and sets the condtion attribute of reference ItemGroup accordingly. Try to search for CustomTask for MSBuild, you found many pre built tasks contributed by communities.

      Regards, Vythees Miles to go before sleep...

      C 1 Reply Last reply
      0
      • V vytheese

        I never tried, but as of my understanding, The Solution file ( *.csProj ) contains the sections to add reference under ItemGroup tag these references are listed. This tag supports condition attribute. So you can write a custom task, which executes under target BeforeCoreGet and sets the condtion attribute of reference ItemGroup accordingly. Try to search for CustomTask for MSBuild, you found many pre built tasks contributed by communities.

        Regards, Vythees Miles to go before sleep...

        C Offline
        C Offline
        Christopher Stratmann
        wrote on last edited by
        #3

        Wow thanks alot. I found this web site which shows that you can have a condition where if the build is set to a certain type then you can include or exclude references. Then in the build I can define something like UsingThirdPartyControls and in my code I can place #if UsingThirdPartyControls #endif. I think this could work. Thanks alot. Chris

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups