conditional compilation
-
I have a shared dll (model.dll) and two executables using it. In teh model library i have a property. In the one executable i would like to set [ReadOnlyAttribute(false)] for the property and in the other executable i would like to set [ReadOnlyAttribute(true)]. Using the conditional compilation settings in the respertive project properties does not do the trick. Does anybody have a suggestion for me?
-
I have a shared dll (model.dll) and two executables using it. In teh model library i have a property. In the one executable i would like to set [ReadOnlyAttribute(false)] for the property and in the other executable i would like to set [ReadOnlyAttribute(true)]. Using the conditional compilation settings in the respertive project properties does not do the trick. Does anybody have a suggestion for me?
Conditional compilation is just that: a compile time operation. If you have two exes using the same DLL, then they will have the same attributes, because the compilation is only done once and the same assembly is being referenced. You can't use it to switch attribute settings at run time! If you want two different attribute settings, then you need to build two separate DLL files - which kinda defeats the point of having it as a DLL in the first place!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
-
Conditional compilation is just that: a compile time operation. If you have two exes using the same DLL, then they will have the same attributes, because the compilation is only done once and the same assembly is being referenced. You can't use it to switch attribute settings at run time! If you want two different attribute settings, then you need to build two separate DLL files - which kinda defeats the point of having it as a DLL in the first place!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
that's clear! Thanks for the reply. Is there realy no smart alternative you can think of? (I use the propertyGrid control)
-
I have a shared dll (model.dll) and two executables using it. In teh model library i have a property. In the one executable i would like to set [ReadOnlyAttribute(false)] for the property and in the other executable i would like to set [ReadOnlyAttribute(true)]. Using the conditional compilation settings in the respertive project properties does not do the trick. Does anybody have a suggestion for me?
As you stated in your last reply to OriginalGriff that you want to use this for a PropertyGrid: Take a look at this article: PropertyGrid utilities[^] - I saw a similar question on another website where one of the answerers said he solved it with the code from that article.
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
-
that's clear! Thanks for the reply. Is there realy no smart alternative you can think of? (I use the propertyGrid control)
-
I have a shared dll (model.dll) and two executables using it. In teh model library i have a property. In the one executable i would like to set [ReadOnlyAttribute(false)] for the property and in the other executable i would like to set [ReadOnlyAttribute(true)]. Using the conditional compilation settings in the respertive project properties does not do the trick. Does anybody have a suggestion for me?
Agreed with OriginalGriff and Sascha, but the big question I would ask is: why do you want this? Best, John
-- Log Wizard - a Log Viewer that is easy and fun to use!
-
Agreed with OriginalGriff and Sascha, but the big question I would ask is: why do you want this? Best, John
-- Log Wizard - a Log Viewer that is easy and fun to use!
the one executable is meant for configution, the other for execution. When executing the operator must not be able to change the properties, but he can observe them.
-
the one executable is meant for configution, the other for execution. When executing the operator must not be able to change the properties, but he can observe them.
Out of the top of my head, I think you should - create some sort of
ConfigurationAPI
class that resides in your dll - you can even apply some credentials at construction (just throw if credentials aren't right) - then the properties you want to configure can all be "internal set" - this way, in yourConfigurationAPI
class you can configure away :) Best, John-- Log Wizard - a Log Viewer that is easy and fun to use!
-
Out of the top of my head, I think you should - create some sort of
ConfigurationAPI
class that resides in your dll - you can even apply some credentials at construction (just throw if credentials aren't right) - then the properties you want to configure can all be "internal set" - this way, in yourConfigurationAPI
class you can configure away :) Best, John-- Log Wizard - a Log Viewer that is easy and fun to use!
i found this: Enabling/disabling properties at runtime in the PropertyGrid[^] thanks for all the replies!