|
Once again you help me, OriginalGriff. I'll Think about. Thanks.
|
|
|
|
|
Good afternoon,
a bit stumped with this one - any help would be greatly appreciated:
System.Void, System.Object, System.Inptr not defined or imported... a little bit stumped with this one... any help would be greatly be appreciated...
Regards,
Pieter Claassens
|
|
|
|
|
As you have been told repeatedly, a couple of words, taken out of context, does not give enough information to know what the problem is. Please show the actual code you are using and explain what you are trying to do.
|
|
|
|
|
Hi, Here is a sample exceprt of the code prudicing the erorr message :
public delegate void CallbackType(bool success, TReturnType returnValue);
Quite a lot of errors/warnings for a one-liner...
|
|
|
|
|
What is CallbackType , what is TReturnType . And did you write this code or are you trying to use something that someone else has written. As I keep saying, please show the full context, that means the code whare the erro(s) occur, and the actual error message(s). A single line out of context, with no accompanying detail, is still not enough. You may know what is showing on your screen terminal but we cannot see it.
|
|
|
|
|
Maybe he's paranoid and doesn't want anyone to see his code. Hence the obfuscation of the types.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Actually I think there is a much simpler answer.
|
|
|
|
|
To add to what Richard has said, the cause of a syntax error isn't always where the compiler reports a problem - it may be in lines before or even after the report!
For example, an additional "}" can cause some odd errors because the class and / o9r namespace has ben "closed" as far as the compiler is concerned, and it doesn't "know" what to do with your code that follows it.
So when you try to report a problem to us, you need to give us more than just one line and an error message - we need context for that and that means maybe a dozen lines either side.
This may help: How to Write Code to Solve a Problem, A Beginner's Guide Part 2: Syntax Errors[^] - it should help you next time you get a compilation error!
And spending a little time learning to understand syntax error messages will save you a huge amount of time in future: you waited at least 1/4 hour for Chris to reply, then your email system probably added another 10 minutes or so, plus the time it took you to type up the question once you had found this site and created an account. Chances are that you could have saved a significant chunk of that time if you knew how to read them!
I'm not saying we don't want to help you fix them - sometimes I can't see my own errors because I read what I meant to write - but fixing syntax errors is part of the job, and if you can't do it for yourself people are going to look at you as a bit weird should you get a job in the industry!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Is possible selected the combobox item not all row but portion row during mouseover item?
best regards
|
|
|
|
|
Not in a standard combobox - it's a single row item which selects the entire item.
What are you trying to achieve that you think you need this: there may be a better way.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Anybody has use the PrintQueueWatch dll for monitor printJobs and printers.
I'm using the PrintQueueWatch dll for a simple app to monitor printers.
I wanna know how to use the function
PrintJob.Transfer.(string printerName, bool transfer)
The function is for transfer the print job to another printer, It's seems very easy to use, the function needs the printer name and a bool value to keep or not the print job in the original printer
but the problem is that always raises an exception
access denied
printQueueWatch collection = new PrintQueueWatch.PrinterCollection();
PrinterInformation printer = collection.Where(l=>l.printername == "the printer that I'm using")
printer.PrinterJobs.getJobById(Id).Transfer("the printer to transfer the printerJob", false) // false to keep the job in the original Printer.
The transfer function says access denied, it seems permissions to acces the new printer.
Thanks
|
|
|
|
|
You should ask whoever publishes the PrintQueueWatch DLL.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
At a guess - and I don't play with print queues so that's all it can be - it's that your app needs elevation, or you need specific permissions to access the two print queues involved.
"Access denied" means you don't have a required permission, so it's likely to be one or the other. Which makes a lot of sense, since the print queue may contain items from multiple users!
The simplest way to check which is to run your app in admin mode and see if the problem goes away.
If it does, then that's what you need - an elevated app.
If it doesn't, then you need to tell the printer queues "who you are" in order to change them. This may help: https://stackoverflow.com/questions/8348743/access-denied-trying-to-purge-printqueue-in-c-sharp[^]
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
I'm trying to detect when an ethernet cable is unplugged from a computer or plugged back in. I have some devices that when plugged in they come up as Unidentified Network(which is normal for the specific device). I'm not looking for internet connection or have anything to do with that. And I think this code works as a trigger:
NetworkChange.NetworkAddressChanged += new NetworkAddressChangedEventHandler(NetworkChange_NetworkAddressChanged);
private static void NetworkChange_NetworkAddressChanged(object sender, EventArgs e)
{
NetworkInterface[] adapters = NetworkInterface.GetAllNetworkInterfaces();
foreach (NetworkInterface n in adapters)
{
MessageBox.Show(n.Name.ToString() + n.OperationalStatus.ToString());
}
}
What I need to do now is to figure out which network adapter was unplugged. I intend to get the operational status of each network adapter. Store it, ask user to power cycle the device and then compare with the stored value(s) to figure out which one has changed from up to down. I'm not sure what the best method to do this would be. Should I do this as an array, list or is there an easier way?
|
|
|
|
|
Surely this return will aid in your finding a good answer to a problem:
CP Search[^]
|
|
|
|
|
In my application I use System.Windows.Forms.DataGrid (not DataGridView!) Unfortunately, I cannot change ColumnHeadersHeight - there is no such property for this control. And secondly, if I increase the row height, text is aligned to the top of row, but vertical alignment is needed. Is there any solution to this problem?
|
|
|
|
|
The old DataGrid wasn't very flexible. You don't have the control over its rendering like you do with the DataGridView.
The only way to SIMPLY get the functionality you want is to drop the DataGrid and replace it with the DataGridView. Otherwise, you're writing a whole bunch of drawing code and drawing the DataGrid yourself. You really don't want to do that.
|
|
|
|
|
When I execute a stored procedure with SqlCommand.ExecuteReader, how do I access the specific result set I need in the case that the stored procedure returns more than one result set?
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
My understanding of this is you can use NextResult to get the next resultset. As it's a firehose, you can't go backwards unfortunately.
|
|
|
|
|
Thanks, Pete!
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
As Pete says, the reader doesn't "rewind" - so I'd probably prefer to use a DataAdapter and fill a Dataset instead of using a DataReader. That way all of the data for all of the sets is available for random access as needed.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Good point, Griff! I didn't know that option existed!
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Hello,
I want to work with a File. I cant get Permission or owner.
Im not the owner of the files as i can see in the propertys.
The Path of the Files are: %userprofile%\AppData\Local\Temp
Here is how i tried to get access owner or permission:
FileInfo info = new FileInfo(path);
FileSecurity security = FileSystemAclExtensions.GetAccessControl(info);
SecurityIdentifier identifier = WindowsIdentity.GetCurrent().User;
security.SetOwner(identifier);
security.AddAccessRule(new FileSystemAccessRule(identifier, FileSystemRights.FullControl, AccessControlType.Allow));
FileSystemAclExtensions.SetAccessControl(info, security);
My goal is to open a FileStream and Write over the File, here is a exaple:
File.SetAttributes(_recycleBin, FileAttributes.Normal);
string[] files = Directory.GetFiles(_recycleBin, "", System.IO.SearchOption.AllDirectories);
foreach (string file in files)
{
try
{
File.SetAttributes(file, FileAttributes.Normal);
double sectors = Math.Ceiling(new FileInfo(file).Length / 512.0);
byte[] dummyBuffer = new byte[512];
RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider();
Trace.WriteLine("DEBUG LOG: " + file + "loaded.");
FileStream inputStream = new FileStream(file, FileMode.Open);
for (int currentPass = 0; currentPass < timesToWrite; currentPass++)
{
inputStream.Position = 0;
for (int sectorsWritten = 0; sectorsWritten < sectors; sectorsWritten++)
{
rng.GetBytes(dummyBuffer);
inputStream.Write(dummyBuffer, 0, dummyBuffer.Length);
}
if (currentPass == timesToWrite - 1)
{
inputStream.Close();
FileSystem.DeleteFile(file);
}
}
}
catch
{
}
}
|
|
|
|
|
Yohan Bischofberger wrote: My goal is ... But what is your question?
|
|
|
|
|
You're going to need to add a manifest to your project.
Add -> Item -> Application Manifest File.
Change the line that says requestedExecutionLevel from level="asInvoker" to level="requireAdministrator"
|
|
|
|