|
Thank you for your help Keshav
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
i have an web application. from here i want start a new process in local mechine. if i start the process it is shown it the task Manager doesn't comes as active window. becase it is runing under ASP.NET user.
is there any way to change the owner for the process before we start?
or
can we bring the aplication intractive with out changing the owner in ASP.NET?
help me
|
|
|
|
|
I have about 3 minutes to dinnertime, so can't look into it too deeply. But here are some links
This forum tells you to go to MSDN and read on Impersonation
http://www.thescripts.com/forum/thread576383.html
Here is the msdn link
http://msdn2.microsoft.com/en-us/library/ms998351.aspx
http://msdn2.microsoft.com/en-us/library/system.security.principal.windowsidentity.impersonate.aspx
hope this gets you going
Visual Studio can't evaluate this, can you?
public object moo<br />
{<br />
__get { return moo; }<br />
__set { moo = value; }<br />
}
|
|
|
|
|
Thank U friends
for u r help
joe
india
|
|
|
|
|
to start a process as a different user, please follow this link
http:
for general process start procedure use this...
http:
Keshav Kamat
India
|
|
|
|
|
Here's an interesting one -- Can someone riddle me this?
Given:
<br />
using System;<br />
<br />
enum Foo { Bar, None }<br />
class Program<br />
{<br />
static void PrintArg(object x) { Console.WriteLine(x.ToString()); }<br />
static void PrintArg(Foo x) { Console.WriteLine(x.ToString()); }<br />
public static void Main()<br />
{<br />
PrintArg(Foo.None);<br />
PrintArg(0);<br />
PrintArg(1);<br />
}<br />
}<br />
Results in the output of:
None
Bar
1
Note: The application of this issue is apparent in the SqlParameter constructors -- If you do SqlParameter param = new SqlParameter("Name", 0); it calls the SqlDbType override, instead of the object value override.
Any ideas why the int 0 isn't acting like the int 1? Is 0 not an int by default?
Chadwick
=============================
I'm a developer, he's a developer, she's a developer, Wouldn'tcha like to be a developer too?
|
|
|
|
|
this is hilarious :p
enum Foo { Bar, None }
static void PrintArg(object x) { Console.WriteLine(x.ToString()); }
static void PrintArg(Foo x) { Console.WriteLine(x.ToString()); }
public static void Main()
{
PrintArg(Foo.None);
PrintArg(Convert.ToInt32(0.ToString()));
PrintArg(1);
}
your problem is very strange
here's the output when you cast it to int, Int32, ...
PrintArg(0);
PrintArg((int)0);
PrintArg((Int16)0);
PrintArg((Int32)0);
PrintArg((Int64)0);
-- modified at 14:16 Wednesday 21st March, 2007
-- modified at 14:17 Wednesday 21st March, 2007
Visual Studio can't evaluate this, can you?
public object moo<br />
{<br />
__get { return moo; }<br />
__set { moo = value; }<br />
}
|
|
|
|
|
So what we're trying to say is that 0 cannot be implicitly boxed by a call to a method if it is in an Int32 valuetype, but it can be boxed if its in an Int16 or an Int64?
Any CLR specialists care to take a stab at this one?
Anyone try this targeting .NET 1.1? Mine is targeting 2.0...
Btw if you call the method as
(object)0 -- it outputs 0 as expected.
I also use Resharper, and when I do a (object)1 it tells me the cast is redundant, but when I do a (object)0, it does not!
=============================
I'm a developer, he's a developer, she's a developer, Wouldn'tcha like to be a developer too?
|
|
|
|
|
this is at least a 7 on the WTF-scale.
Visual Studio can't evaluate this, can you?
public object moo<br />
{<br />
__get { return moo; }<br />
__set { moo = value; }<br />
}
|
|
|
|
|
Code sample:
<br />
PrintArg(0);<br />
PrintArg((int)0);<br />
PrintArg((Int16)0);<br />
PrintArg((short)0);<br />
PrintArg((Int32)0);<br />
PrintArg((long)0);<br />
PrintArg((Int64)0);<br />
PrintArg(1);<br />
Corresponding IL:
<br />
.method public hidebysig static void Main() cil managed<br />
{<br />
.entrypoint<br />
.maxstack 1<br />
IL_0000: nop<br />
IL_0001: ldc.i4.0<br />
IL_0002: call void Program::PrintArg(valuetype Foo)<br />
IL_0007: nop<br />
IL_0008: ldc.i4.0<br />
IL_0009: call void Program::PrintArg(valuetype Foo)<br />
IL_000e: nop<br />
IL_000f: ldc.i4.0<br />
IL_0010: box [mscorlib]System.Int16<br />
IL_0015: call void Program::PrintArg(object)<br />
IL_001a: nop<br />
IL_001b: ldc.i4.0<br />
IL_001c: box [mscorlib]System.Int16<br />
IL_0021: call void Program::PrintArg(object)<br />
IL_0026: nop<br />
IL_0027: ldc.i4.0<br />
IL_0028: call void Program::PrintArg(valuetype Foo)<br />
IL_002d: nop<br />
IL_002e: ldc.i4.0<br />
IL_002f: conv.i8<br />
IL_0030: box [mscorlib]System.Int64<br />
IL_0035: call void Program::PrintArg(object)<br />
IL_003a: nop<br />
IL_003b: ldc.i4.0<br />
IL_003c: conv.i8<br />
IL_003d: box [mscorlib]System.Int64<br />
IL_0042: call void Program::PrintArg(object)<br />
IL_0047: nop<br />
IL_0048: ldc.i4.1<br />
IL_0049: box [mscorlib]System.Int32<br />
IL_004e: call void Program::PrintArg(object)<br />
IL_0053: nop<br />
IL_0054: ret<br />
}
Notice the lack of a box operation any time the Int32 0 value is used... consistent with the call to the wrong function void Program::PrintArg(valuetype Foo) ... but notice the correct box op for the call with 1!?!?
Quirky... I am almost convinced this is a compiler bug.
The only work around I can think of is to do the following:
<br />
using System;<br />
<br />
enum Foo { Bar, None }<br />
class Program<br />
{<br />
static void PrintArg(object x) <br />
{ <br />
if (x is Foo) <br />
{ <br />
PrintFooArg((Foo)x); <br />
return; <br />
} <br />
Console.WriteLine(x.ToString()); <br />
}<br />
<br />
static void PrintFooArg(Foo x) <br />
{ <br />
Console.WriteLine(x.ToString()); <br />
}<br />
<br />
public static void Main()<br />
{<br />
PrintArg(0);<br />
PrintArg((int)0);<br />
PrintArg((Int16)0);<br />
PrintArg((short)0);<br />
PrintArg((Int32)0);<br />
PrintArg((long)0);<br />
PrintArg((Int64)0);<br />
PrintArg(1);<br />
PrintArg(Foo.Bar);<br />
}<br />
}<br />
It prints everything as expected....
=============================
I'm a developer, he's a developer, she's a developer, Wouldn'tcha like to be a developer too?
|
|
|
|
|
try
PrintArg(-0);
and
Console.WriteLine(0.GetType() == 1.GetType());
and the resharper making it redundant is _very_ odd to say the least. I use it too. It usually looks up whether your type cast has any purpose for this specific case. f.e. casting 0 into object for the purpose of .GetType'ing makes it redundant, because it also has this option without the cast.
Visual Studio can't evaluate this, can you?
public object moo<br />
{<br />
__get { return moo; }<br />
__set { moo = value; }<br />
}
|
|
|
|
|
|
Now I know we're not crazy
From Microsoft --
Thanks for your feedback. We have reproduced this bug on <winxp pro="" sp2,="" vsts="" sp1="">, and we are sending this bug to the appropriate group within the Visual Studio Product Team for triage and resolution. Thank you, Visual Studio Product Team.
Posted by Microsoft on 3/22/2007 at 12:21 AM
=============================
I'm a developer, he's a developer, she's a developer, Wouldn'tcha like to be a developer too?
|
|
|
|
|
Hmmm. Bart De Smet, C# MVP had this to say:
For the C#-compiler, the token 0 is parsed just as a token of course; it depends on the context what the semantic will be. Nevertheless you can often just think of 0 as a int (= System.Int32) constant. For the following discussion, I've used this piece of code:
using System;
class Program
{
enum Foo { Bar, None }
static void PrintArg(object x) { Console.WriteLine("O {0}", x.ToString()); }
static void PrintArg(Foo x) { Console.WriteLine("F {0}", x.ToString()); }
public static void Main()
{
PrintArg(Foo.Bar);
PrintArg(Foo.None);
PrintArg((Foo)0);
PrintArg((Foo)1);
PrintArg(0); // Implicit cast to Foo.Bar
PrintArg(1);
PrintArg((int)0); // Implicit cast to Foo.Bar
PrintArg((int)1);
PrintArg((Int32)0); // Implicit cast to Foo.Bar
PrintArg((Int32)1);
PrintArg((Int16)0);
PrintArg((Int16)1);
PrintArg((Int64)0);
PrintArg((Int64)1);
PrintArg((object)0);
PrintArg((object)1);
}
}
You'll see the following as the output:
F Bar
F None
F Bar
F None
F Bar
O 1
F Bar
O 1
F Bar
O 1
O 0
O 1
O 0
O 1
O 0
O 1
Let's start with the first pair. Nothing weird in here; just a case of strong typing and a one-on-one match for a method to be called. Essentially, enums are first class citizens when it comes down to object typing. Behind the scenes, an enums is an int however (in the default case).
The second pair is the same as above; using an explicit cast from to the enum type. On the method overload resolution side of the story, there's no difference with the case above.
On to pair three. In here, something different happens. C# only allows implicit conversion of the decimal-integer-literal 0 to any enum (section 6.1.3 of the C# 2.0 standard); other literals don't have implicit conversions (so you need to do something like in case 2). Therefore, the first invocation will result in a call to the Bar argument method overload, while the second one doesn't. Any type, including value types likes an int, derives from System.Object, so the other overload is called (boxing happens though behind the scenes).
Pair four and pair five are the same since int and Int32 are equivalent in C# due to the built-in type mapping. Therefore, (int)0 and (Int32)0 are the same as just 0, resulting in the decimal-integer-literal 0, allowing implicit conversion to the underlying enum type. Output will be "F Bar", "O 1" again because of the reason aforementioned (6.1.3).
The cases represented by pairs six and seven do not match the rule above; although it's a bit subtle. Because we do a cast of 0 to Int16 in the first case, the compiler looks for the best overload for a PrintArg method with an Int16 parameter; since it's not an Int32, rule 6.1.3 doesn't hold, so we end up with the object parameter case. So, there no second-level implicit casting from the Int16 to Int32 to end up in the 6.1.3 case, as some might think. For case seven, it's the same (although there wouldn't be an implicit cast from Int64 to Int32 possible at all, so less doubt about this should be around).
The last two cases are self-explanatory. You tell the compiler to look for an object parameter, so it does.
To explain the philosophy behind rule 6.1.3, just think of enums as a value type with a typical "default" of 0. This makes simple initialization possible, without relying on the underlying enum's names:
Foo f = 0;
However,
Foo f = 1;
won't work. Furthermore, this corresponds to the underlying CLR strategy of all value types to be "all zeros" initialized, so C# allows developers to state this explicitly as they might expect to be possible.
This being said, one should obey to the design guidelines for frameworks. The following rule applies: "Do provide a value of zero on simple enums". As the matter in fact, the Foo enum in the sample doesn't follow this rule:
enum Foo
{
None = 0,
Bar
}
would have been much better. If you think about it this way, allowing only 0 assignment for enums perfectly makes sense.
-Bart
It sorta makes sense the way he puts it. If it really is a documented 'feature', it probably behaves like it should. Still pretty weird shtuff.
Visual Studio can't evaluate this, can you?
public object moo<br />
{<br />
__get { return moo; }<br />
__set { moo = value; }<br />
}
|
|
|
|
|
Yes, I got the same general response from MS... Section 13.1.3 of the ECMA standard states that the decimal-integer-literal 0 can be implicitly cast to an enum type. It does not, however, provide the same rationale as your MVP friend said.
It definitely displays the stated behavior, because if you do int x = 0; then pass x as your parameter, it does the box properly. I kindof see the point in why the standard is the way it is now. I still think that it should at least generate some sort of level 4 warning or something... it is not like all of us have the time (or the brain space) to memorize the ECMA and C# 2.0 standards...especially one as esoteric as this.
=============================
I'm a developer, he's a developer, she's a developer, Wouldn'tcha like to be a developer too?
|
|
|
|
|
Chadwick Posey wrote: esoteric
Lois Griffin: Peter, it's great they picked your theme, but isn't it a little esoteric?
Peter Griffin: Esoteric...?
[Cut-scene: inside Peter's head]
Man 2: Could it mean sexy?
Man 3: I think it's a science term.
Man 4: Fellas, fellas, esoteric means delicious.
[Back to reality]
Peter Griffin: Lois, Who's the Boss? is not a food.
Brian Griffin: Swing and a miss.
I'm sorry, big words usually provoke funny movie or TV quotes, rather than their actual meaning. I'm not a retard, just not native-english-speaking
Visual Studio can't evaluate this, can you?
public object moo<br />
{<br />
__get { return moo; }<br />
__set { moo = value; }<br />
}
|
|
|
|
|
Hi,
I am working on a simple database project and I am confused about data bindings between DataSet, DataView and DataGrid objects.
I connect to a database, I build my DataSet, I bind it to a DataView, which I bind to a DataGrid.
My DataGrid displays my stuff correctly, but I was wondering how I can make a change to my DataView so that both my DataGrid and my DataSet will take these changes as well...
And if I make a change to my DataGrid, will the change be present in both my DataView and My DataSet? And if I make a change to my DataSet, will it be reflected in the DataView and the DataGrid?
How does all thes things work?
Thank you very much!
|
|
|
|
|
You can also bind a dataset to a datagrid directly
DataSet dataSet=new DataSet();
DataGrid1.DataSource=dataSet;
Similarly, at anytime, you can bind the contents of a datagrid to a dataset.
DataSet dataSet=new DataSet();
dataSet = (DataSet)DataGrid1.DataSource;
Keshav Kamat
India
|
|
|
|
|
Hello experts!
I'm coding a component which inherits from TextBox.
To provide one of the functionallities I want, I need to read the text box's content, analyze it, change it, and write the new string to the TextBox , every time the user types something.
I initially thought that by overriding the OnTextChanged() method, and changing the value of the Text property inside its code I would get a stack overflow, but I was curious for the result so I kept on coding...
When I type something in the TextBox everything works perfect, and I don't get any stack overflows...
However, if I put a break point inside of the OnTextChanged() method, and then type only a single char in the TextBox , the breakpoint hits twice.
How could it be?
Is it possible that the control automatically stops the calls to OnTextChanged() when it detects a possible stack overflow??
Thanks in advance,
Shy.
|
|
|
|
|
won't the break point hit twice because you are changing the text in the OnTextChanged handler, causing the TextChanged event to fire again?
|
|
|
|
|
Correct...
But why is it stopping there?
With this logic, it means that more calls to OnTextChanged() would be made... Right?
|
|
|
|
|
Only if you're making changes to what's stored in the .Text property. If you reset the .Text property with a string that's exactly like the one it already has, the event won't fire again because nothing's changed.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I see...
So the comparison the control is doing is not case sensative than, because what I'm doing is making upper<->lower string changes...
Thanks,
Shy.
|
|
|
|
|
No, unless you specify otherwise, a string compare is case-sensitive. The point is, if the user enters 'a', and you change it to 'A', you will not change it to 'A' again because it is already 'A'. Therefore, the handler will be called only twice.
|
|
|
|
|
I would like to put a C# project of mine under configuration control. I'm wondering, what actually needs to go in there for the project to be usable in the future.
Say i have ProjectX.
There is a ProjectX folder, with a ProjectX.sln and a ProjectX.suo in there.
Then ProjectX/ProjectX has all of my class files.
And then there is ProjectX/ProjectX/Properies
And then ProjectX/ProjectX/bin
What is actually necessary to keep, or is all if it necessary?
Any tips on a better way to organize it?
Thanks in advance!
|
|
|
|
|