|
Hello everyone,
I've got a project and I am making a version 2 of this project. Though still version 1 must be active and used.
So I'm using preprocessor directives to assign the extra parts for the program for version 2. But in this case I have to place a #define VERSION_2 in every file where I want to make a difference between version 1 and version 2.
I would like to know if it is possible to put a #define in one file and use it in another file.
For example:
#define VERSION_2
namespace Prog.test
{
class test
{
#if VERSION_1
doThat();
#elif VERSION_2
doAnother();
#endif
}
}
namepace Prog.chair
{
class chair
{
#if VERSION_1 //does not work, because not defined
setHeight();
#elif VERSION_2 //does not work, because not defined
setWidth();
#endif
}
}
|
|
|
|
|
You can define them in the project properties:
Project -> (Name) Properties -> Build -> Conditional compilation symbols
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Thank you very much! That's all I needed
|
|
|
|
|
I would think the best way to accomplish backwards compatibility is to derive a new class from the original, and then the calling assembly can use whichever version it wants. No need for compiler directives at all.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Why not using branches on a version control system (like SVN)? Sure, this makes things a bit complicated but should keep the code pretty clean.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
0) He's talking about making an assembly compatible between versions. Source control is completely out of context.
1) Just because you *can* make it more complex, doesn't mean you should.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Hi all.
Hopefully someone will be able to give some pointers. I've written a small COM object using C# which is basically a form containing a axwebbrowser object.
The problem i'm having is that when i instantiate my COM object using VB script i am unable to get the web browser to accept any keyboard input. I can click links on pages and navigation works fine, but I can't get it to accept any kind of keyboard input.
|
|
|
|
|
i used some 3rd party tools and mine also in an app, now i want to secure those dlls. I used some tools and software those merge the assemblies with exe but i dont like that way because it slow down the startup of app, bugs and many other reasons. Therefore, i thought to copy all the dlls in users' system32(64) directory or any other and it can be done but how to change the path of dlls, mean how to tell my app that read the dll from that directory instead of reading from its own. Any idea ?
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
Xmen wrote: Therefore, i thought to copy all the dlls in users' system32(64) directory
Don't do that.
Xmen wrote: mean how to tell my app that read the dll from that directory instead of reading from its own. Any idea ?
you can't. It will check it's own dir first, then it will check the directories such as system32 if it can't be found locally. What's your security concern - that people will replace your dll with their own ? They can always decompile yours, anyhow, so you've lost that battle before you start.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
He could a) strongly name them (detects rogue replacement), and then b) run an obfuscator on them. Most of the commercial obfuscators can merge assemblies, encrypt strings, and create native Windows binaries, so that would solve the decompile problem.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Christian Graus wrote: Don't do that.
reason ?
Christian Graus wrote: They can always decompile yours, anyhow, so you've lost that battle before you start.
nono, i dont scare of decompile. I know noone can prevent their dlls or exes. All i just want to hide the dlls, my app should look like single exe app. thats it.
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
Xmen wrote: All i just want to hide the dlls, my app should look like single exe app. thats it.
The best way to do that is to merge the assemblies.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
John Simmons / outlaw programmer wrote: merge the assemblies.
hehe how simply you said that, any way ?
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
You can use IlMerge[^] to merge managed assemblies.
|
|
|
|
|
yupp mate, i tried that too but that thing is very typical. After spending hrs on that i had nothing new
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
Because one feature of .NET is meant to be that you can copy a folder and move it to another machine to redeploy. Also, because those folders get polluted with too much crap and it's better not to contribute. Finally, if some other app has a dll with the same name as yours and they go to the same place, what happens then ? Oh, if you have to release more than one version of the sale dll, putting them in the app folder means you can safely do that.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
yeah i agree with you but dude understand this situation...this is different, no connection with any rule or anything. E.g. a best friend of you that says to you to make an app for him/her and (s)he says also that app must be single exe then what will you do. Wont you develope one ? Will you say him/her that this is poor design ?
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
If you place dlls in other directory, you can use Appdomain.AssemblyResolve event to point your application to the dll it needs. But as everyone can look into your application, they will be able to see the directory where the dlls reside.
|
|
|
|
|
Giorgi Dalakishvili wrote: But as everyone can look into your application, they will be able to see the directory where the dlls reside.
yes, thats biggest drawback of .net applications
anyway i have to do what i need i will try Appdomain.AssemblyResolve
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
If you strongly name the assemblies and install into the GAC you won't need to go to this trouble.
You could also use the config file to tell where your assemblies are located
Assembly Placement[^]
You may also want to review this article How the Runtime Locates Assemblies[^]
Moving assemblies around just so your app appears as a single file is a poor design and deployment choice anyway.
only two letters away from being an asset
|
|
|
|
|
Mark Nischalke wrote: Moving assemblies around just so your app appears as a single file is a poor design
yes i know, but im not gonna sell it or noone gonna purchase it. Its for someone else, someone special.
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
Poor design is still poor design whether its for you or a thousand people.
only two letters away from being an asset
|
|
|
|
|
Now I have to wonder about your intent and motives...
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Hi,
I would like to create application that support main menus, toolbar and popup menus.
I know I can define one function and related all events ‘Click’ to this function.
I would like to define shortcut, tooltip and image for each GUI interface such as main men, tool bar and popup menu.
Is there an option to define it one time and relate it to each control?
I know I have in Borland type call ‘Action’ that can define the event function and property such as tooltip, shortcut and then define the action in each control
That way I define it one time and not three times for each option in GUI
Thanks
Ronen
|
|
|
|
|
Ronenb wrote: Is there an option to define it one time and relate it to each control?
Sure, you can create one method and point all of your events to it. That's about it, really.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|