Conditional namespace

Hi Everyone,

I want to include the namespace "using Windows7.DesktopIntegration" in my C# 
project only if the current OS is Windows 7, for other OS like Xp,2000,vista 
I need to ignore the same.

Any idea for achieving this will helpful for me.

-- 
Thanks and Regards,
Shankar B.
0
Utf
12/8/2009 10:56:01 AM
dotnet.languages.csharp 1931 articles. 0 followers. Follow

4 Replies
770 Views

Similar Articles

[PageSpeed] 5

Shankar wrote:
> Hi Everyone,
> 
> I want to include the namespace "using Windows7.DesktopIntegration" in my C# 
> project only if the current OS is Windows 7, for other OS like Xp,2000,vista 
> I need to ignore the same.
> 

I'm puzzled. AFAIK the only reason you would need to include a namespace 
is if you are referencing classes, enums, etc. from it. If you are, and 
those classes, etc., only exist in Windows 7, then what do you expect 
your app to do on another OS?
0
Harlan
12/8/2009 3:52:07 PM
Shankar wrote:
> Hi Everyone,
> 
> I want to include the namespace "using Windows7.DesktopIntegration" in my C# 
> project only if the current OS is Windows 7, for other OS like Xp,2000,vista 
> I need to ignore the same.
> 
> Any idea for achieving this will helpful for me.

The "using" directive is a compile-time feature.  You cannot 
conditionally exclude it based on the OS version on which your program 
is executing.

If you want to use features in an assembly (such as "Windows7.DLL" or 
similar, whatever that is...seems to be some sort of interop code 
example provided by Microsoft?) that may not be present always, I 
believe you'll need to use reflection to load the assembly dynamically.

Pete
0
Peter
12/8/2009 5:47:22 PM
I may be wrong, but I think that a namespace through a using will be 
effectively 'loaded' ONLY if your code ever access it. So, if your code use 
compiler directives ( #if  / #endif )  such that a namespace is never 
effectively referenced by your code, there is few to no penalty by keeping 
the initial using refereeing to an un-used namespace (unless doing so you 
got collisions/ambiguities in your way).


Vanderghast, Access MVP


"Shankar" <Shankar@discussions.microsoft.com> wrote in message 
news:EF3EFB17-BC3E-40FF-AADD-34FCC1BD2741@microsoft.com...
> Hi Everyone,
>
> I want to include the namespace "using Windows7.DesktopIntegration" in my 
> C#
> project only if the current OS is Windows 7, for other OS like 
> Xp,2000,vista
> I need to ignore the same.
>
> Any idea for achieving this will helpful for me.
>
> -- 
> Thanks and Regards,
> Shankar B. 

0
vanderghast
12/9/2009 4:04:37 PM
vanderghast wrote:
> I may be wrong, but I think that a namespace through a using will be 
> effectively 'loaded' ONLY if your code ever access it. So, if your code 
> use compiler directives ( #if  / #endif )  such that a namespace is 
> never effectively referenced by your code, there is few to no penalty by 
> keeping the initial using refereeing to an un-used namespace (unless 
> doing so you got collisions/ambiguities in your way).

Minor nit:

Namespaces aren't referenced, assemblies are.  You can have one assembly 
define types from multiple namespaces, and you can have types from a 
single namespace implemented in multiple assemblies.

But yes, you can reference an assembly in another assembly, and as long 
as there's not actually any code _present_ in that assembly that calls 
into the other assembly, you can successfully use the other assembly 
without the first.  Note that it's whether the code is _present_ or not 
that's important; simply avoiding executing the code isn't sufficient. 
It has to not be there at all.

Note that the "using" directive has nothing to do with this at all.  It 
doesn't count as "code" for the purposes of the requirement of an 
assembly being present; you can have a "using" directive for a namespace 
in the assembly, but as long as you don't actually have any executable 
code using the assembly, it's still fine for it to not be there.  On the 
other hand, if you do have code using the assembly, eliminating the 
"using" statement is not sufficient to eliminate the dependency on the 
assembly.

The important thing to keep in mind here is that whether an assembly 
needs to be present or not is entirely determined at compile time, 
unless you use some kind of dynamic loading technique (e.g. reflection, 
as I suggested in my other reply).  And of course, at compile time you 
don't know what version of the OS the application is actually executing 
on, or what other libraries may be present (*), unless you actually 
build specific versions of the code intended to be run on only specific 
versions of the OS or with specific libraries present.

Pete


(*)  (not counting dynamically generated and compiled code, of 
course...there was no mention of that in the original question, and it's 
rare enough we should be able to assume it's not a consideration here)
0
Peter
12/9/2009 8:03:44 PM
Reply:

Similar Artilces:

Today Conditional Format
I have a column which calculated a date based on 3 working days from a date input into a diff column. What I want to do I have the calculated date appear bold if that date has passed based on the current date. For example if I input 01/08/11 the next column calculates 04/08/11 (3 working days). I want the caluclated date to appear bold when I open the spreadsheet on the 05/08/11 ro show the calculated date has passed. I can use conditional formatting but can't get the syntax right Regards Andy Win XP Pro Office 2010 Andy Roberts presented the following explanation : > I ha...

Two Condition Vlookup?
I am currently trying to create a function that searches through an array for two exact column values which allows me to retrieve a third column value. For example: Type of Fruit Date Packaged Amount of Fruit Apples June 100 Oranges June 50 Apples July 75 Grapes July 50 In this example, I would be looking to retrieve the Amount of Fruit (Apples) that was packaged in July. I would be putt...

Need help with conditional formula (Excel 97)
Can anyone give me the correct syntax for the following formula: if A1 is blank, and B1 is more than zero, then display B1, otherwise display nothing (blank cell) Thank you JD =IF(AND(A1="",B1>0),B1,"") Success! -- met vriendelijke groetjes "Jake D" <JakeD@djhtend.com> schreef in bericht news:crkto4lv30u7uujv27ek8okr0us5t9oj10@4ax.com... > Can anyone give me the correct syntax for the following formula: > > if A1 is blank, and B1 is more than zero, then display B1, otherwise > display nothing (blank cell) > > Thank you > > ...

Query condition by date range
I'm trying to create a query to base a report from. I need it to return records within a date range that needs to be specified, as in specifying the beginning date and having the current date as the end date. A field is included in the query that has listed dates in the format mm/dd/yyyy. How would I write the criteria? I have part of it ready - [Please enter starting date:] . I know that's how you get the little question window. On Tue, 4 Dec 2007 14:51:00 -0800, silva wrote: > I'm trying to create a query to base a report from. I need it to return > records within a...

Conditional formatting if condition of an if statement is true and a string value is displayed
Dear Experts: I got a nested 'IF'-Formula in an excel cell that returns nothing if the condition is false. I would like to conditionally format this cell with grey shading if the condition is true and a string value is displayed. How can this be achieved using excel conditional formating functionality ? Help is much appreciated. Thank you very much in advance. Regards, Andreas Let's say your doing this conditional formatting in cell K17. In conditional formatting (xl2003) choose the FormulaIs: option and enter: =$K$17<>"" choose your formatt...

Conditional Field in Queries
Is there a way to make a field in a query conditional so that it only displays the value if the value is equal to something specifically set? Thanks. Nick Nick.Korynski@gmail.com wrote: > Is there a way to make a field in a query conditional so that it only > displays the value if the value is equal to something specifically > set? Thanks. > > Nick Explain "the value is equal to something specifically set". -- Rick Brandt, Microsoft Access MVP Email (as appropriate) to... RBrandt at Hunter dot com ...

How do i use Conditional formatting for 3+ conditions ?
I have a text box in a report which highlights in colour current members in a list of past and present member names. I have six types of current members that I want to highlight, but with conditional formatting I can only use 3 conditions in the members [Type] field. I have tried [Type]="Full member" Or "Life member" but the "Or" doesn't work ! Is there a way to do this ? thanks .. Roger CF is limited to 3 contitions, but you can use OR in those expressions. If you set Condition1 to Expression, you can use: ([Type] = "Full member") Or (...

Conditional null value
Wondering if anyone can suggest a way to simplify the following code, which I’m using in the OnFormat event of a report. If Not IsNull(DLookup("[ICD2]", "EntryICDs", "[EntryNum] = " & Me! [PtAcct#])) Then Me![Field192] = Replace(DLookup("[ICD2]", "EntryICDs", "[EntryNum] = " & Me![PtAcct#]), ".", " ") End If If Not IsNull(DLookup("[ICD3]", "EntryICDs", "[EntryNum] = " & Me! [PtAcct#])) Then Me![Field194] = Replace(DLookup("[ICD...

Help with Conditional formatting with Dates
Hi there, I have a spreadsheet in which I have to monitor various dates which are in different columns (i.e. (1) Date Tender Released, (2) Date Company Selected, (3) Date Draft Contract Forwarded, (4) Date Contract Signed etc...). Would if be possible to Conditional Format and have diffirent ROWs highlighted for each individual Contracts (I have 300 running contracts running) every time a date is filled in these different columns: Initial Step (1) = Yellow (Call for Tender released) Step (2) = Blue (Company Selected) Step (3) = Brown (Contract under Process) Step (4) = Green (Contract Si...

Help
Forgive me if "Conditional Sums" is not the accurate word for what I am trying to accomplish... I'm at a loss for what to call this situation. What I have is a spreadsheet totaling attendance figures for classes taught by two people (Dave and Cary). Column A lists their name, and next to it in Column B is the number of people who attended that class. What I need is a formula that will look at the sheet and report in a given cell the total for attendance for each person. I can work basic formulas like SUM, but that will give the total for the entire column, when what I n...

XML Receipt and Conditions
I wanted to make a small adjustment to the receipt when a certain condition is met. If a particular word (eg. family) is typed into the comment on an item I wanted something slightly different to happen to the receipt I've just about got it, just stuck on the condition tag <IF> <CONDITION>len(Entry.Comment)</CONDITION> <THEN> I can get it using len but this makes it happen for any word, is there anyway I can make it so that it is more specific ie Entry.Comment contains '%family%' try <IF> <CONDITION>Entry.Comment like '%family%'&...

conditionally restricting values in excel
Hello, I want to restrict values in a particular column based on the value in other column. For eg. if column A has value int then column B should be restricted to values 1,2,3,4,5 if column A has value bool then column B should be restricted to values true and false. if column A has value string I dont want any validation to be done and the list box should not appear. Is this possible..... How do I achieve this ? Can I use macros to do this? How? Thanks Hi as a starting point: http://www.contextures.com/xlDataVal02.html >-----Original Message----- >Hello, >I want to restrict ...

Conditional formating condition..?
Hi All I have 2 CF conditions associated with a cell (C14), one of which is: Formula is =OR($C$4="Fred SOMEBODY",C14<>"10:30:00") What happens when this is true isn't important/relevant. The value in the cell appears as 10:30 (formatted as custom/hh:mm) but the value in the 'formula window' is actually 10:30:00. This type of condition works fine when the cell contains a simple number (or text) but I can't get it to work for either times or dates. I have tried it with and without the inverted commas (around the time value) and have tried using 10:30 ...

Condition Formatting!
How do I make a row of cell (shading) that change to red color when the word "trial" or "limit" is entered? i.e cell 3f contain the word "trial". From the column of trial to the 1st column, the entire row 3a to 3f will be red? a b c d e f 1 2 3 Trial 4 5 6 Here's some VBA you could paste into the codebehind page for that sheet: Private Sub Worksheet_Change(ByVal Target As Range) If UCase(Target.Value) = "TRIAL" Or UCase(Target.Value) = "LIMIT" T...

chart conditional formatting
I have a line chart with 3 lines, red, blue and green. Is there any way I can conditionally format some, but not all, points on the red line to colour white - ie make them invisible. I have looked at Jon Peltier's site - he addresses conditional formatting - but cannot see a solution there. Thanks in advance to all who try to help. -- bob777 ------------------------------------------------------------------------ bob777's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=28504 View this thread: http://www.excelforum.com/showthread.php?threadid=488635 Hi, Ha...

Conditional Picture?
Does anybody knows how to insert one picture that changes without use intervention everytime the result of another cell changes? eg.: If the cell A1="Alex" the cell A2=Picture of Alex. Then if change the cell A1 to "Mike" the cell A2 displays the picture of Mike -- Message posted from http://www.ExcelForum.com Hi Alex This macro example from this group a long time ago you can use. The jpg files must have the same names as the number you type in cell "a1" Change the path to the files in the code. Place the code in the Sheet module Right click on a sheet tab ...

.NET & XSLT: Unwanted namespace in resulting file after using extension objects
Hello, after using extension objects in the stylesheets there's an additional namespace entry in the resulting file. How can I prevent that? See: ..NET/C#: XslCompiledTransform xslt = new XslCompiledTransform(); .... XsltArgumentList xsltArgs = new XsltArgumentList(); xsltArgs.AddExtensionObject("ibd:DanTe", this); .... xslt.Transform( _source, xsltArgs, target ); XSLT: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/ Transform" xmlns:ibd="ibd:DanTe"> &l...

Conditional Formatting for 4 conditions
How can I set up conditional formatting for the following: >3.5 = red 2.5 - 3.49 = yellow 2 - 2.49 = green <2 = blue Thanks, Steve Set all the cells to one of the colours that apply the 3 conditions to them via CF, effectively 4 colours. -- HTH Bob "Steve" <Steve@discussions.microsoft.com> wrote in message news:3E34D7F5-545C-4177-83C7-93A735398F42@microsoft.com... > How can I set up conditional formatting for the following: > >>3.5 = red > 2.5 - 3.49 = yellow > 2 - 2.49 = green > <2 = blue > > Thanks, &...

About stopping container to resize on some condition
Hi I am new in this group. I am using Docking window in my application. When I dock more than one window to each other. I read that it creates container for all that panes. Now when I am docking 3-4 windows horizontally , It create one vertical resizing bar. I want that bar remove and also remove the facility of resizing on some condition. but window should not be undocked. It must be in same position and also I must able to resizing horizontally. Just I want to turn off the vertical resizing as well as remove vertical bar or make it thinner. If anyone has any solution. Please ma...

Conditional, Conditional Formatting
Two questions, both have to do with semi-complex (at least for me) conditional formatting. 1) I have two conditional formatting "formulas" on column B. Depending on the corresponding row in column I, I want the conditional formatting on or off. If I3 = 0, then don't allow conditional formatting for b3. 2) I want cells from column A to be "strikethrough" if the corresponding cell in column I equals zero. Is there any semi easy (from a data entry standpoint) way for this to be accomplished? Thanks, John One way: Say your current CF for column B is to...

Filter For Conditional Format
I have a group of cells that have conditional formatting based on th answers from another group of cells. I want to try to filter for cells that have a conditional format tha been turned on. If an employee is on vacation his cell for that week changes color. I he has hours of work scheduled that will be a problem. I'm trying t filter to see an conflicts without looking at the rows individually. Thanks in advance Frank Haverkamp frank.haverkamp@btecsolutions.co -- Message posted from http://www.ExcelForum.com Frank, Chip Pearson addresses this question on his Website. Look here: http...

conditional cell format
Can I set some aspect of the cell format based on a formula value? For example, I would like to change the cell fill color based on whether the value in that cell is greater than or less than a value in another cell. -- Gary King Take a look at Format|conditional formatting Gary King wrote: > > Can I set some aspect of the cell format based on a formula value? > > For example, I would like to change the cell fill color based on whether the > value in that cell is greater than or less than a value in another cell. > > -- > Gary King -- Dave Peterson Suppose ...

Conditional formatting from other sheet
I am trying to make a following conditional formatting Change the color of a cell in a range, if its value is maximum of the range. The maximum value of the range is calculated through Tools/Data/Analysis/Descriptive Statistics, which I have not reside in the same sheet. But conditional formatting doesn’t accept to use reference from other sheet. Is there any solution for this issue? Also it doesn’t work when I put the formula Max(range) in the conditional formatting reference box. One way is to use named ranges Eg in Sheet2, the CF formula used could be: =B2=MAX(MyRange1) where: MyRan...

Workflow : Wait activity condition does not work
I've created a very simple workflow that does not seem to work. The rule is: Manual Rule Task: Task 1 wait Task: Task 1 is completed end wait Task: Task 2 When I 'Save as completed' Task 1, Task 2 is not created. I find the following entry in the EVent Log: Event Type: Error Event Source: MSCRMWorkflowService Event Category: None Event ID: 16649 Date: 11/1/2007 Time: 1:42:25 PM User: N/A Computer: AMCI-CRMPROD Description: Condition {BF1490AE-A188-DC11-9C5C-00C09F1E9CAA} failed in step {BB1490AE-A188-DC11-9C5C-00C09F1E9CAA} of process instanc...

Conditional Formatting
I have a spreadsheet where I have set a data validation for the colum to select from a list. The list has names of colors. (Red, yellow, etc) A total of 6 colors. I then set a conditional format for the column to change the background of the cell to the selected color. (The word "red" displays in cell and background color of cell is red). Excel limits the number of conditions to 3. I have 6 color condtions (red, yellow, green, blue, brown, black). How do I get around the 3 limit condition where I can set all 6 colors to change when the text is selected from the drop down. Hi...