|
Can CR5 inherit from both iCR and iCRComm?
|
|
|
|
|
Your definition and use of iCRComm is what my iCR interface is. It's still not doing what my iCRComm does. Thanks for helping!!
|
|
|
|
|
Yes; although I don't see why one wouldn't simply modify the original interface to include the new method. Remember that the factory is there for a good reason.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Yes, but I have two factories. One for CR5 interface and one for CRComm interface. It may not be obvious from what I posted, but they have very different uses. Generic needs to use CR5 for writes. CR5Comm is used all over the place and definitely isn't the same/can't be condensed into one with CR5. You're changing the use of everything too much for it to be helpful. Maybe we need to go back to the original VS project definitions of everything? I know it's difficult, but it's like that for a reason. Even where you put the delegate doesn't translate to anywhere in my code.
|
|
|
|
|
MichCl wrote: It may not be obvious from what I posted, but they have very different uses.
I'd expect anything out that factory to behave similar; otherwise you'd be checking whether you're working on a CR5 or a CR6 everywhere in code, making things even more complicated.
MichCl wrote: Even where you put the delegate doesn't translate to anywhere in my code.
As far as the compiler is concerned, it's located in "some" namespace. As long as it's referenced, it can be used.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Like I said. There are two different factories. One for comm, one for crx. I get two different things from them. The fact that I don't have a check for CR5 or CR6, is because my cr factory returns an instance of iCR that is an instance of either cr5 or cr6. When I make a call from my instance of icr that is returned, it will automatically go to the implementation of cr5 or cr6, whichever I instantiated in the factory.
I realize the compiler doesn't care about the delegate location and usage, but I do. The structure/fix that you are suggesting doesn't translate even slightly to my code, which is in separate vs projects. I can't put my delegate where you have it, so it's not a fix for my problem. Thanks for the help!
|
|
|
|
|
MichCl wrote: The structure/fix that you are suggesting doesn't translate even slightly to my code, which is in separate vs projects.
Aight, can you add in the project names in the original post? Make 'em fake ones if required
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Thanks! I updated the original post with vs project names.
|
|
|
|
|
Did you see the changes I made to the original post?
|
|
|
|
|
I did, but I won't be able to work on it until I am home
|
|
|
|
|
Guess what???! I cleaned all of my classes, detached and re-attached references, and it's working now. I guess I had the delegates/events and the interfaces set up correctly after all!!!! I was stepping through and noticed an exception was being thrown so I wasn't getting to my event setup (+/-), so that's why it was null and missing updating the progressBar. Thanks for the help!!
|
|
|
|
|
MichCl wrote: Guess what???! I cleaned all of my classes, detached and re-attached references, and it's working now. Cool!
MichCl wrote: Thanks for the help!! You're welcome
|
|
|
|
|
It seems like the place you're putting the delegate won't work for me since you have it all in one program and I don't. I see that it works, though.
|
|
|
|
|
How to view the images from folder one by one by clicking next and previous button in c#
|
|
|
|
|
Exactly how you do it depends on teh environment, which you don't specify. For a web based solution it would be different from a WinForms version.
Winforms is easy (but even then there are a number of ways to do it):
Read the list of image files (using Directory.GetAllFiles)
Set a class level index to 0.
Show the first image, by loading it (using Image.FromFile) into the Image property of a PictureBox.
When the next button is pressed, increment the index, and show that one. Similar for the previous button.
The universe is composed of electrons, neutrons, protons and......morons. (ThePhantomUpvoter)
|
|
|
|
|
im using windows application
|
|
|
|
|
DirectoryInfo di = new DirectoryInfo(@"C:\YourImgDir");
FileInfo[] Images = di.GetFiles("*.jpg");
or try this
var path = Server.MapPath("...");
var images = Directory.GetFiles(path, "*.png");
foreach (var image in images)
{
System.Console.WriteLine(image);
}
modified 3-May-13 9:28am.
|
|
|
|
|
code is simple:
System.Diagnostics.Process.Start("sc", "\\\\" + strMachine + " config \"<the service name>\" start= demand");
not getting any exception or anything. My code is impersonating a domain user that has admin rights on that box. I know the impersonation code is working because I use it elsewhere.
Also, if I do a runas command prompt and run the command line manually, it successfully works, so I know the username and password are correct. Just can't do it from C#.
I can't see if its spitting out any errors as the dos box flashes too fast.
Any ideas?
|
|
|
|
|
Don't build the command line argument string inside the Start method. Build it into a variable so you can see EXACTLY what is being sent to the Start method.
|
|
|
|
|
Yeah, I've done that and its EXACTLY what I ran under the runas command. I've tried both the code I posted (while impersonating the domain account that has admin rights) as well as the version of Start where you pass in the username, password & domain. In addition, as proof that my impersonation code is working, I'm able to start & stop the service remotely with the service control manager class. I'm also able to execute pskill remotely (to kill a process).
|
|
|
|
|
SledgeHammer01 wrote: I've done that and its EXACTLY what I ran under the runas command
Seriously?? "<the service name>" ?? That's not exactly what you're running at the command line...
If you're getting the black CMD window to show up and then disappear, it means that you're:
1) Launching the command as a user that doesn't have permissions to execute the SC command on the target machine.
2) The service name isn't correct.
3) Something else in the command line isn't correct.
To check to see who the command line is running as, change the Start call to launch .Start("CMD", "/K WHOAMI")
After you've verified who the command is running as, you can alter your command line to launch the SC command and have to command prompt stick around: .Start("CMD", "/K <your entire SC command line here>")
Oh, remember what I said about building the command line in a seperate variable?? This is where is comes in handy...
|
|
|
|
|
Dave Kreskowiak wrote: Seriously?? "<the service name>" ?? That's not exactly what
you're running at the command line...
You know that I "censored" that for the forum, right?
Dave Kreskowiak wrote: 1) Launching the command as a user that doesn't have permissions to execute the
SC command on the target machine.
As I stated, I can start and stop the service with the Service Control Manager class, so the user is correct.
Dave Kreskowiak wrote: 2) The service name isn't correct.
As I stated, I can start and stop the service with the Service Control Manager class, so the service name is correct.
Dave Kreskowiak wrote: Oh, remember what I said about building the command line in a seperate
variable?? This is where is comes in handy...
As I stated, I did that.
Dave Kreskowiak wrote: After you've verified who the command is running as, you can alter your command
line to launch the SC command and have to command prompt stick around:
.Start("CMD", "/K <your entire SC command line here>")
I will try this.
|
|
|
|
|
So I tried the CMD /K WHOAMI and got the non-impersonated user. If I try using the overload of .Start() that has a username & password, I get an Access Denied exception (even when using my current credentials). When I do CMD /K <my sc="" command="" line="">, I also get access denied. I think however the cmd tests are invalid tests because when I do a RunAs impersonatedusername / impersonateduserpassword, it works correctly, but that command prompt window can't do a lot of things. Like it can't interact with the desktop for example.
I have verified the sc command line via a variable as you suggested and it is correct. I even copy and pasted it into the run as'ed command window to make sure I didn't miss some small thing and it worked. If I run it via the Start, the window flashes too fast to see. If I run it via the cmd /k, the window stays around, but I get an access denied.
Not sure whats going on
|
|
|
|
|
SledgeHammer01 wrote: I think however the cmd tests are invalid tests because
Nope. You're running a command line app and the command prompt is telling you who it's running as. If the user isn't what you expected it to be, well, that's a problem in your code, not the test. This is telling you who the SC command is running as. If that account doesn't have the appropriate permissions to the target machine to start and stop services, it's going to fail.
SledgeHammer01 wrote: but that command prompt window can't do a lot of things
Such as?? Oh, let me remind you that that statement has absolutely nothing to do with running a command line app, like SC!!
SledgeHammer01 wrote: I even copy and pasted it into the run as'ed command window to make sure I
didn't miss some small thing and it worked.
That command ran as YOUR account. All it does is veryify the command is correct, NOT that it's going to work under the account your code is using (you mentioned impersonation) or the Start method you're calling is using (you said you used one of the overloads that takes a username and password).
SledgeHammer01 wrote: If I run it via the cmd /k, the window stays around, but I get an access
denied.
This is because the command prompt you launched isn't running as the user you think it is. I already told you how to find out what the command you launch with Start is running as. It's simple really. "Access denied" means the account you launched the command with doesn't have permissions to do what you want.
|
|
|
|
|
Dave Kreskowiak wrote: Nope. You're running a command line app and the command prompt is telling you
who it's running as. If the user isn't what you expected it to be, well, that's
a problem in your code, not the test. This is telling you who the SC command is
running as. If that account doesn't have the appropriate permissions to the
target machine to start and stop services, it's going to fail.
Ok Mr. Smarty Pants (j/k)... explain this one... I have just proved again that the impersonation code I am using is working:
using (new Impersonator(_strDomain, _strUsername, _strPassword))
{
System.Diagnostics.Debug.WriteLine(System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToString());
System.Diagnostics.Process.Start("CMD", "/K WHOAMI");
}
I have just conducted two tests there... your CMD /K WHOAMI (which returns the wrong non-impersonated logged on user) and WindowsIdentity.GetCurrent() (which CORRECTLY returns the impersonated user!)
I am running on Windows 7 as an admin on my box (but not the remote box), UAC is disabled. So that block of code *is* running as the impersonated user, but Process.Start() seems to be running as non impersonated currently logged on user.
|
|
|
|