|
You use the indexer "[]"
eg
ArrayList a;
...
object o =a[2];
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|
|
Hi!
I want to create a application which have a tab control in where it should host a axwebbrowser for each tab.
So far no problem, but everytime i add a new instance of the axwebbrowser it creates about 10mb more memory usage.
And thats not nice ... i know that you can copy instance with
axwebbrowser2 = axwebbrowser1
but then you have to set the location configs again to them and i mean it's not the nicest and cleaniest way
to do this! And the axwebbrowser1 is gone, so if i go back to the first tab i have to copy it back
axwebbrowser1 = axwebbrowser2
and add the location config again to the first webbrowser.
I searched for this on Google and here at CP but i can't find any solution. Maybe someone can help me out of this
Thanks
Matthias
|
|
|
|
|
Hello,
I have a number of Asserts in my code, ASP.NET application, and all they ever seem to do it show up in the output window.
I'd like when the Assertion fails that the code stops (like in the MFC applications I used to write) Well, I do have a bit of a work around, but it is kludgy and make my code look really inelegant.
From
Debug.Assert(AssertionCondition==false, "Something went wrong");
I now have to write:
#if DEBUG
if (AssertionCondition == false)
{
Debug.Assert(false, "Something went wrong");
}
And stick a breakpoint on the Assert Line.
Is there a simpler way to achieve the same?
--Colin Mackay--
"In the confrontation between the stream and the rock, the stream always wins - not through strength but perseverance." (H. Jackson Brown)
|
|
|
|
|
if (AssertionCondition == false)
{
Debugger.Break();
}
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|
|
Thanks.
--Colin Mackay--
"In the confrontation between the stream and the rock, the stream always wins - not through strength but perseverance." (H. Jackson Brown)
|
|
|
|
|
Hi, I have an interesting problem. I create an input form a while back, and continued development in other areas. Now all are finished, and I went back to test the input, and it does not work. It gives me some error about " not being in the column. You see, I did not touch that section, so am very surprised it reports that, as it did work. However, when I run it by pressing F5 (with debugging), there is no error. I have switched between the two modes a few times, and cannot work out why it runs with debugging, but not without.
Anyway, the final problem, is when I run the executable, it comes up with an error, system.IO.FileLoadException.
Has this happened to you before? I would supply some code, but as I dont know which part it is that causes this, I have not.
|
|
|
|
|
Could you be doing something in code that is conditionaly on the configuration. (i.e. Debug Vs. Release)
Check your code for #if DEBUG blocks that may be doing extra work in debug mode that isn't being done in release. Or Debug.Assert calls because they only get evaluated in Debug builds.
As an example of what I mean. Run the following program in Debug and release mode and note the difference.
using System;
using System.Diagnostics;
namespace WeeTester
{
class Class1
{
private static int _i = 0;
[STAThread]
static void Main(string[] args)
{
Console.WriteLine("_i={0}", Add());
Debug.Assert(Add()==1, "_i != 1");
Console.WriteLine("_i={0}", Add());
Console.ReadLine();
}
private static int Add()
{
return _i++;
}
}
}
You will see that in Debug mode the output is:
_i=0
_i=2
and in Release the result is:
_i=0
_i=1
because the call to Add() in the Debug.Assert is not made anymore.
--Colin Mackay--
"In the confrontation between the stream and the rock, the stream always wins - not through strength but perseverance." (H. Jackson Brown)
|
|
|
|
|
I am working on a application that uses Direct3D. The problem is that I want to use a vertexshader, but I don't know how !!
Can someone tell me how?
Greetings....
|
|
|
|
|
Look at MS Highlevel Shader Language. (i just know the name, something like that)
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|
|
Hi.
I have written a windows service running in LocalService account and I want to check the username of the user logged on to the computer. How can I do this? I have tried
1) Environment.UserName, "LOCAL SERVICE" was returned
2) System.Security.Principal.WindowsIdentity.GetCurrent().Name, which returned "NT AUTHORITY\LOCAL SERVICE"
It is logical that I get this result but not what I want. How can I check who is logged on to the computer?
Thanks
/EnkelIk
|
|
|
|
|
try something like this
WindowsPrincipal myPrincipal;
myPrincipal = (WindowsPrincipal) System.Threading.Thread.CurrentPrincipal;
WindowsIdentity myIdentity;
myIdentity = (WindowsIdentity)myPrincipal.Identity;
MessageBox.Show(myIdentity.Name);
|
|
|
|
|
I'm afraid I can't get it to work. The cast
(WindowsPrincipal) System.Threading.Thread.CurrentPrincipal generates an invalid-cast-exception, so I tried
string strUser=System.Threading.Thread.CurrentPrincipal.Identity.Name;
but the resulting string is empty. Have I missed something?
Thanks
/EnkelIk
|
|
|
|
|
I'm sorry, I didnt test the code, I just assumed it would work
You need to add this before the cast
AppDomain.CurrentDomain.SetPrincipalPolicy (PrincipalPolicy.WindowsPrincipal);
Regards,
Kannan
|
|
|
|
|
Thanks, that helped on the exception. Unfortunatelly the name returned is: NT AUTHORITY\LOCAL SERVICE
so back to where I started more or less...
/EnkelIk
|
|
|
|
|
This isn't a simple task.
The user physically sitting at the computer always uses the window station named WinSta0 . You can use the unmanaged APIs OpenWindowStation and GetUserObjectInformation with the UOI_USER_SID flag to get the user's security identifier or SID. You can then LookupAccountSid to discover the associated username.
|
|
|
|
|
Thanks.
That seems to be the way to do it. I implemented it as a separate module and my problem now is that it works fine when I run it from a normal exe, but not when I run it from the service -it's as if I can't even create an instance of the module class. Sigh.
Thanks
/EnkelIk
|
|
|
|
|
What is it supposed to return if there is no user logged on?
It is a windows service. No UI. If a user is logged on then
it returns the logged on user name. The Environment class
has a UserInteractive property.
Thank You
Bo Hunter
|
|
|
|
|
I'm not sure yet. If no user is logged on, it is supposed to return something (an empty string perhaps or a null reference) from which I can tell that no user is logged on. I'm working at a university and part of the idea with the service is to have it listening for calls from a program 'gathering' information on the computers and to be able to answer whether someone is logged on or not and then the calling program display the rooms where there are, say three or more, free computers on monitors placed on different locations on campus. The students will then be able to see where a free computer can be found.
/EnkelIk
|
|
|
|
|
I have two ListBox's ... listBox1, listBox2 ... I want to use the list boxs to obtain values from the "row" and "column" indices from an initialized multidimensional array. listBox1 will grab the "row" value, and listBox2 will grab the column value. I will display the data in a read-only text box... can anyone help me figure this out ???
Thanx ... total newbie to programming Windows .... I can do this in DOS ...
but I have no clue how to get the listbox to "tie-in" to my ..
double[,]DataArray = {{ values here },
{ " " },
{ " " },
{ " " }};
Chris R
|
|
|
|
|
Hi!
Please help me with this. I want to make a program that inherits
from two third party classes. (Let's just call it ClassA and ClassB)
I know I cannot do multiple inheritance so I need to use interface.
But I don't know how. Please help.
"To teach is to learn twice"
|
|
|
|
|
i found this site with excelent tutorials on c#
this is chapter 7 , that teach abstract classes & interfaces
http://www.programmersheaven.com/2/les_csharp_7_p1
|
|
|
|
|
I have already read that site. It doesn't answer my question.
Actually the problem here is that, the classes are THIRD PARTY CLASSES.
It already has existing methods that I need to use. Thanks anyway.
"To teach is to learn twice"
|
|
|
|
|
If the methods in the third party classes that you are interested in are public, then you do not need to use any inheritence, multiple or single. Simply use objects of these classes.
Otherwise if the methods are protected, then subclass both the third party classes, yourself, and add public methods in the subclasses, that use the protected methods of your interest. Then use your subclasses, instead of the original third party classes. This is kind of a hack.
In either case, you can avoid inheriting from those third party classes.
|
|
|
|
|
Use inheritance for one class and containment for the other:
class C : A
{
private B b;
public void SomeMethodInB()
{
b.SomeMethod();
}
public int SomeOtherMethodInB()
{
return b.SomeOtherMethod();
}
...
}
Regards,
Alvaro
Can I ask you a question?
|
|
|
|
|
i wanted to create a nice midi program in c# as my first app
i had little experience with directx so i downloaded this time the whole package including managed-directx, installed it and ...
i cant find direct-music in managed directx ???
maybe im missing something but i couldnt find midi support!
if im missing something or there is another api that has midi for c# please tell me, and is it planned to add directmusic to managed directx soon ?
|
|
|
|