|
The code you've been given will do what you asked. The user interface to make it work is so trivial that if you can't do it, you deserve to fail your class. Giving it to you would be doing you a disservice, and would be doing an even bigger disservice to the rest of your class, who I presume have paid attention.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
diddy34 wrote: and i promise not to be like this
Too late! You already are!
If you can't drag and drop a couple of controls on a form, what makes you think you'll be able to do it next time?
-- modified at 7:48 Thursday 3rd August, 2006
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
First : learn how to open Visual Studio
Second : learn how to drag and drop control to form
Third : try to write the code of your own
Fourth : Problem?? Ask CP.
You are now just finishing number ONE, go to number TWO, not number FOUR.
|
|
|
|
|
i am connecting to a different domain to access the service control manager using the service controller and the impersonate LogonUser. I can connect to the domains but on certain machines i get the error Cannot open Service Control Manager on xxxxx. This operation might require other priviliges.
I have logged onto the machine to see the priviliges and they are fine. The login i am using has the act as part of operating system.
i am using xp on the source machine but the target machine is using windows 2000.
The code for the impersonater is the following
public class ImpersonateUser<br />
{<br />
[DllImport("advapi32.dll", SetLastError = true)]<br />
public static extern bool LogonUser(<br />
String lpszUsername,<br />
String lpszDomain,<br />
String lpszPassword,<br />
int dwLogonType,<br />
int dwLogonProvider,<br />
ref IntPtr phToken);<br />
<br />
[DllImport("kernel32.dll", CharSet = CharSet.Auto)]<br />
public extern static bool CloseHandle(IntPtr handle);<br />
<br />
private static IntPtr tokenHandle = new IntPtr(0);<br />
private static WindowsImpersonationContext impersonatedUser;<br />
<br />
[PermissionSetAttribute(SecurityAction.Demand, Name = "FullTrust")]<br />
public void Impersonate(string domainName, string userName, string password) {<br />
try {<br />
<br />
const int LOGON32_PROVIDER_WINNT50 = 3;<br />
const int LOGON32_LOGON_NEW_CREDENTIALS = 9;<br />
tokenHandle = IntPtr.Zero;<br />
<br />
bool returnValue = LogonUser(<br />
userName,<br />
domainName,<br />
password,<br />
LOGON32_LOGON_NEW_CREDENTIALS,
<br />
LOGON32_PROVIDER_WINNT50,<br />
ref tokenHandle);
<br />
<br />
if (false == returnValue) {<br />
int ret = Marshal.GetLastWin32Error();<br />
Console.WriteLine("LogonUser call failed with error code : " +<br />
ret);<br />
throw new System.ComponentModel.Win32Exception(ret);<br />
}<br />
<br />
WindowsIdentity newId = new WindowsIdentity(tokenHandle);<br />
impersonatedUser = newId.Impersonate();<br />
<br />
}<br />
catch (Exception ex) {<br />
Console.WriteLine("Exception occurred. " + ex.Message);<br />
return;<br />
}<br />
}<br />
<br />
public void Undo() {<br />
impersonatedUser.Undo();<br />
if (tokenHandle != IntPtr.Zero)<br />
CloseHandle(tokenHandle);<br />
}
i have used every combination of LOGON32 and the PROVIDER.
The service controller code is as follows
ImpersonateUser iU = new ImpersonateUser();<br />
<br />
iU.Impersonate(DomainName, UserName, Password);<br />
System.ServiceProcess.ServiceController [] myController1;<br />
myController1 = System.ServiceProcess.ServiceController.GetServices("10.8.2.120");<br />
<br />
foreach( System.ServiceProcess.ServiceController controller in myController1 )<br />
{<br />
<br />
MessageBox.Show(controller.ServiceName);<br />
}
the message box is just to test if i can access the service control manager.
The error i think is from the service controller. Can anyone help?
-- modified at 12:32 Thursday 3rd August, 2006
Rick
|
|
|
|
|
Hi,
I believe i understand the concept of delegates. To put it simply, I think they are used to invoke methods in another class.
What I don't quite understand is:
What is the point of using delegates when you can easily call the method in the other class the normal way which is create an iinstance of the class and then call the method.
Can you please help to understand this issue?
Thanks
|
|
|
|
|
fmardani wrote: What is the point of using delegates when you can easily call the method in the other class the normal way which is create an iinstance of the class and then call the method.
Because a delegate creates a link between classes where there often isn't one. For example, I create a form, form1. It has a modeless child, form2. I want to call a method in form1 when something happens in form2. Now, I CAN make a reference to form1 inside form2, but that's kind of ugly. Delegates are a nicer solution. Events can also be chained, so calling one event can call methods in several class instances. That's all happening for you, for free.
Every time I go back to C++, delegates are the first thing I miss. Yes, I have function pointers, but it's a lot more work.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
|
In oop its an usual practice for an object to send a message to another object, itq common for an object to report back to the sender, resulting in two way conversation between objects (callback methods).
C, C++ did this using function pointers.
C# does it using delegates. Its a special type of object which contains details about the method rather than the data.
They are used for two purposes
1. Callback
2. Event handling
i hope this helps
---------------------------------------------------------------
where there is a will there is a way
|
|
|
|
|
I have the following problem:
i want to be able to fill a class with data in the client side which uses my web service and then send that class to one of its web methods.
For this purpose, i used [Serializable] attribute above all my classes in the web service that should be available in the client side for that purpose.
The problem is that i can see the classes in the client side, but can't call their methods and properties even though they are public.
how can i do that? is there an attribute which should be used above each public method/property of a class which is marked Serializable?
Thanks.
-- modified at 5:30 Thursday 3rd August, 2006
|
|
|
|
|
Create an bject for the Class in the web service in your Application
For Eg
WebApplication1.MyWebservice1.Service1 ObJEct = new WebApplication1.MyWebservice1.Service1();
ObJEct.methdName();
By this you can call the Web methods and propertiesof your Web Services.
Hope this Solves your problem.
note : You should Add [WebMethod] attribute on top of all the methods in the web service to make the methods visible to your client ..
-- modified at 17:27 Thursday 3rd August, 2006
Luck is Opportunity with hardwork
|
|
|
|
|
This is not the case...
The problem is not with the Web service's methods (which are woking just fine). it is with classes that are used to create an object that should be used by the client to fill information.
let's say i have the following in the web service's class "Service1":
-----
[WebMethod]
public string test(MyInfo TestData)
-----
Now, "MyInfo" is a class which has other classes as attributes which have properties/methods. In the client side, i want to be able to fill the TestData class with information (and its internal classes) and send it to the method. These are the methods/properties i want to be able to use in the client side.
So, to be able to see all the classes that MyInfo holds, i used [XmlInclude] attribute for each of these classes.
now - i can create these classes and see them in the client, but all their properties/methods i cannot see even though they are public.
|
|
|
|
|
Hi all
Can i retrive from hashtable objects in those seqency in which ones had been added to one.
I mean
<br />
<br />
ht.Add("key1", object1);<br />
ht.Add("key2", object2);<br />
ht.Add("key3", object3);<br />
<br />
foreach(DictionaryEntry de in ht)<br />
{<br />
WriteLine(de.Key);<br />
}<br />
<br />
------------------<br />
result can be as this:<br />
<br />
key3<br />
key2<br />
key1<br />
<br />
how i can do what:<br />
<br />
key1<br />
key2<br />
key3<br />
<br />
Thank
|
|
|
|
|
I don't believe so, no. A hash table, by definition, stores according to hashes. If you need the order, you need to store them in a list or something as well.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
I belive in what i saw
When in watch window i debug this hashtable i saw what all entries walk in ordem in which i add ones .Since what i think should exist any mechanism for retrive ones in same ordem.
Please ,any key ,get me opinion :
i need any ordered collection and simulatently
key-value-pares in one. Which type of collection i should use.
Thank.
-- modified at 5:23 Thursday 3rd August, 2006
|
|
|
|
|
A hashtable does not retain the order that the items were added in. If the items were displayed in the same order you added them, it was a coincidence.
---
b { font-weight: normal; }
|
|
|
|
|
You can make sure in this. Try to oneself.
When displayed items in ordem, when retrived not.
ht.Add("one", null);
ht.Add("two", null);
-----
Displayed:
ht
["one"]
["two"]
------
Retrived
two
one
-- modified at 5:51 Thursday 3rd August, 2006
|
|
|
|
|
Use SortedList instead of Hashtable.
|
|
|
|
|
Thank think this is exactly what i need
|
|
|
|
|
hi all i have this pro on hand now.. i have downloaded some sample database applications from the internet..however when i want to debug it i gives me the error--An unhandled exception of type "system.Data.OleDb.OledbException" occurred in system.data.dll
and also the database is in access format but when i want to open it it gives a message--the file is located outside yr intranet or on an untrusted site. Microsoft Access will not open the file due to potential security problems.TO open the file, copy it to yr machine or an accessible network location.
i inferred that this errors occur due to where the dB file is located..is it correct? can someone out there help will this pro? and maybe guide me to correcting it ..thanks in advance..
|
|
|
|
|
Probably you need to right click the MDB file and mark it as trusted, it's probably marked as having come from the web.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
hi u are right! i can access the DB now but my application still have debugging errors with the same message which i first posted here.. how can i solve it??
|
|
|
|
|
Well, now we're at the point where you need to tell us the error and post some code.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
can u share he link with me from where u downloaded that sample applications with databse please
|
|
|
|
|
Hi all,
How to select a particular treenode in TreeView using index or object
|
|
|
|
|
this.treeView1.SelectedNode = this.treeView1.Nodes[0];
|
|
|
|