|
|
First, You can assign only System.Drawing.Color to Button1.Backcolor.
Second, you need to create new derived button class or Create custom control, to be able to assign your own properties, to your needs. (Custom Control Example[^]
♫ 99 little bugs in the code,
99 bugs in the code
We fix a bug, compile it again
101 little bugs in the code ♫
|
|
|
|
|
Hello,
I am working on application which use Apple iPod. We check weather device is connected using WMI query.
We are using NUnit for unit testing. Every-time we need to check function which searches device we need to plug-in iPod. But just for unit testing, having iPod not seems to be feasible.
Can we add virtual device, so we can detect it using WMI, without having device physically present.
Thanks in Advance.
Happy Programming.
|
|
|
|
|
Only if you get out the device driver kit and write a device yourself.
It would be FAR easier and quicker to plug in any old iPod.
|
|
|
|
|
Thanks Dave. I think you are right.
|
|
|
|
|
Agreed.
I have encountered situations like this where devs have hacked in bypass code to manipulate results. This, of course, invalidates the test both in principle and validity, so please, please DO NOT DO THAT as a work-around.
[Edit]Sorry, Dave, I replied to your answer and not the OP's comment.[/Edit]
I wasn't, now I am, then I won't be anymore.
|
|
|
|
|
Depends on what you are testing.
Obviously writing a pseudo driver is an ideal situation since it not only lets you test against something real but also allows you to simulate errors which might not be possible with a real device.
If you are mainly concerned about testing your code rather than the actual interface layer then you can, carefully, insert a layer that handles the ONLY the API. That layer is implemeted with interfaces (C# type). That allows you to replace them in your unit tests with suitable pseudo code.
|
|
|
|
|
I'm having a problem with a web service in my C# code. I've consumed the web service by adding a web reference and all is good, the reference is consumed correctly I'm getting all my proxy types flow through etc. etc.
When I run a method on the service, however, the returned object is null and no exceptions are thrown:
MethodResponse response = service.Method(methodRequest);
I'm running Fiddler in the background (HTTPS decryption is turned off, even though I'm simply running on HTTP) and I'm getting a legitimate XML response back - it maps perfectly to my response types. I've added some code where I can manually copy the XML response from Fiddler into the code, use an XmlDeserializer, and it works just fine.
I have noticed one thing, though. The request I send has an XML declaration at the beginning of it, whereas the response does not. If I set up Fiddler's auto-responder with the legit response and add an XML declaration to it, I get an exception:
There is an error in XML document (120, 15).
Unexpected end of file while parsing Name has occurred. Line 120, position 15.
That line and position are a bit of a red-herring, as they don't point to anything useful in particular (not even the EOF), and as I said before, the XML is valid. Also, there is no Name element in the XML at all, so I'm assuming it means that it's trying to parse a tag name (which one it doesn't say), not finding the end of it for whatever reason and then passing the EOF.
Any ideas as to what's going on or where I should look next?
Typical n-tiered architecture:
DB <-> Junk(0) <-> ... <-> Junk(n-1) <-> Pretty
|
|
|
|
|
Hi,
i have a set of directive(in listbox) in my application, which contain certain condition..
i need to add this condition from the response which i got in the form of xml and want to change the condition for those directive whose value is changed by the user from frontend application and for those which is unchanged i need to add the condition from the response which i got already in the form of xml..
could u tell me how to do it...
this is my code...
Directive DADirective = new Directive();
Directive[] daDirArray = new Directive[oDirective.Length];
for (int j = 0; j < oDirective.Length; j++)
{
DADirective = new Directive();
DADirective.DirectiveName = oDirective[j].DirectiveName;
DADirective.DirectiveDescription = oDirective[j].DirectiveDescription;
DADirective.Priority = oDirective[j].Priority;
DADirective.Default = oDirective[j].Default;
daDirArray[j] = DADirective;
}
DAData.Directive = daDirArray;
List<SetValueType> SetValueTypeList = new List<SetValueType>();
GetValueTypeCondition(gValueTypeCondition, SetValueTypeList);
daDirArray[selectedindex].SetValueType = SetValueTypeList.FirstOrDefault();
List<Condition> Conditions = new List<Condition>();
List<Group> GroupList = new List<Group>();
getCondition(gCondition, Conditions, GroupList);
int intcount = Conditions.Count;
if (intcount == 1)
{
if (Conditions[0].Field.FieldID != "")
{
daDirArray[selectedindex].Condition = Conditions.ToArray();
for (int i = 0; i < intcount; i++)
daDirArray[selectedindex].Condition[i].LogicalOperator = strLogicalOpt;
}
}
else
{
daDirArray[DirectiveIndex].Condition = Conditions.ToArray();
for (int i = 0; i < intcount; i++)
daDirArray[selectedindex].Condition[i].LogicalOperator = strLogicalOpt;
}
daDirArray[DirectiveIndex].Group = GroupList.ToArray();
string strRequest = GenerateXMLForDerivedAttibute(gdar);
}
|
|
|
|
|
Hi,
I have asked a question regarding convesion of List to DataTable.
Here is the link of question.
Conversion of List to DataTable
Please answer on this question.
Thanks in advance.
Regards
AR
|
|
|
|
|
1. Cross-posting is considered rude. Pick one place to ask your question and stay there unless some senior member tells you otherwise.
2. You already have two answers, essentially the same, with 3 links between them. Why do you think you will get anything different here? (Remember Einstein's definition of insanity - doing the same thing over and over and expecting a different result.)
Software rusts. Simon Stephenson, ca 1994.
|
|
|
|
|
So can you please help me for the same on either place?
|
|
|
|
|
The answers you got are valid. There is no way to do this without iterating through the List because there is no conversion between a List and a DataTable. Even if there was, interanlly, it would be iterating over the List anyway.
|
|
|
|
|
|
|
Or Bing? Sorry it's a joke spilling over from the Lounge.
Craigslist Troll: litaly@comcast.net
"I have a theory that the truth is never told during the nine-to-five hours. "
— Hunter S. Thompson
|
|
|
|
|
You have 2 answers to your QA question, can you please accept them? It is pretty rude not to reward people that took the time to help you.
Craigslist Troll: litaly@comcast.net
"I have a theory that the truth is never told during the nine-to-five hours. "
— Hunter S. Thompson
|
|
|
|
|
Hello
I have problem with following:
Have WinForm app, in which i have PDF Viewer axAcroPdf, and in startup, i load pdf file with form fields in it.
Next, I have button, which when it pressed, need to read changes made by user in loaded pdf file in viewer, and use this data..
User have "save" button on controls bar of viewer, which ask user when and how save copy of file. I don't need that, and i disabled that controls bar.
Is there any way to perform that save button of viewer with predefined path and filename?
I had idea to programatically save that updated file like temp file, and open it with iTextSharp PDFReader, and use that data from populated fields in pdf file, and delete than delete temp file, but i have no idea how to perform that save button from control bar of viewer..
i'm using c# 2010
thanks
|
|
|
|
|
64 bit Console linked to 32 bit dll? I know and in fact tried it won't work. You can add reference but you'd have runtime exception "Could not load fle or assembly ... one of its dependencies. An attempt was made to load a program with incorrect format"
But have I missed anything? Any magic whereby 64 bit host can reference and load a 32 bit dll into its process?
dev
|
|
|
|
|
Windows does not support heterogeneous processes, each process has to be either entirely 32-bit or entirely 64-bit, there is no way around that.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
I created some client server code that talks back and forth to each other using TCPListener -> TcpClient -> NetworkStream. Everything it working great. The data being sent from the client is showing up on the server with data intact. However, there is one problem; the data is out of order.
A simple example is:
Client sends:
1 2 3 4 5 6 7 8 9 10
and the Server receives:
1 2 3 5 6 7 8 4 9 10
I'm happy that the 4 makes it there but I'd just like it to come after the 3.
Is this a short coming of the TCP stack? Am I asking too much? I know tcp is supposed to ensure that data gets there but does it ensure that it gets there in order?
Some psuedo code as to the main line items:
m_Listener = new TcpListener(m_ServerPort); <-- Port 8000 if it matters
m_Listener.Start();
TcpClient m_Client = m_Listner.AcceptTcpClient();
NetworkStream m_NetworkStream = m_Client.GetStream();
The below code is run in a thread devoted to reading in data from that network stream. This thread code is via a BackgroundWorker.
while (m_Client.Connected)
{
byte[] buffer = new byte[4];
int readBytes = m_NetworkStream.Read(buffer, 0, 4);
if (readBytes == 0)
break;
ChatCommandType cmdType = (ChatCommandType)(BitConverter.ToInt32(buffer, 0));
string cmdTarget = "";
buffer = new byte[4];
readBytes = m_NetworkStream.Read(buffer, 0, 4);
if (readBytes == 0)
break;
int ipSize = BitConverter.ToInt32(buffer, 0);
buffer = new byte[ipSize];
readBytes = m_NetworkStream.Read(buffer, 0, ipSize);
if (readBytes == 0)
break;
cmdTarget = System.Text.Encoding.ASCII.GetString(buffer);
}
There is more to the read in code but this is the gist.
It runs rock solid except when the entire messages get flipped.
I'd appreciate any random thoughts on this. I've been banging my head on it for 2 days now and need a fresh pair of eyes.
I could implement my own sync code where it won't send 5 until it gets a response on 4 but I thought TcpClient would be the one to handle that and not higher up the stack.
Thanks,
|
|
|
|
|
There probably is way too much information missing here, you haven't shown the sending stuff at all, and it isn't clear to me where exactly the two receiving code snippets are located (and they only deal with the internals of a message, not what happens to the messages as a whole). How many threads are involved? etc.
If you want to get this solved, I suggest you add logging, i.e. sending short lines of information (with HH:mm:ss.fff timestamps, and the current thread ID (I suggest the lowest byte in hex), and essential data values) to a file, for both the sender and the receiver.
BTW: I noticed there isn't any safety built in; when a stream gets out of sync, the wrong bytes may end up forming a length value, or negative bytes may end up being ASCII decoded. You should never assume all will go right all the time!
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
TCP does preserve order, so if you are seeing this, then either you are sending the data out of order, or your receiving code is messing with the order. If you are sending or receiving in multiple threads for the same socket then that could happen, for example if to create the 'numbers' you are spinning off execution of each one to a thread pool or something.
You haven't posted any sending code which I suspect is where the problem lies, as it is unusual to have more than one thread reading the same socket, though if you were doing that it could also mess things up.
By the way your receive code is quite unsafe. Think about what happens if you receive 3 bytes, or 11. Check ClientInfo.ReadInternal from my sockets library to see how to cope with this.
|
|
|
|
|
Octantis wrote: I'd appreciate any random thoughts on this
Besides what is said by the others....
You have some 'method' that you are using to determine what "order" the packets represent.
That 'method' is flawed. Thus you think the order that is being sent is "1 2 3 4 5..." but in fact it is "1 2 3 5 ...4"
|
|
|
|
|
I think you and the others might be right with them being sent in the wrong order.
I believe this is what is happening. I spawn a fire and forget thread to send out the data. I think the system is servicing the threads in a different order than what they were created. I use a semaphore on the socket to ensure the writing is done without interruption from other threads ensuring the whole message is sent out. I'm thinking I just need to use a single sending thread and build a queue for outgoing data.
I'm working on tracking the threads to verify my claim. I'll post more when it shows up.
BTW thanks for the help. You guys simply saying check your sending code was enough to make me take a second look. I appreciate you taking the time to read this.
Tim
|
|
|
|
|