For those new to message boards please try to follow a few simple rules when posting your question.
Choose the correct forum for your message. Posting a VB.NET question in the C++ forum will end in tears.
Be specific! Don't ask "can someone send me the code to create an application that does 'X'. Pinpoint exactly what it is you need help with.
Keep the subject line brief, but descriptive. eg "File Serialization problem"
Keep the question as brief as possible. If you have to include code, include the smallest snippet of code you can.
Be careful when including code that you haven't made a typo. Typing mistakes can become the focal point instead of the actual question you asked.
Do not remove or empty a message if others have replied. Keep the thread intact and available for others to search and read. If your problem was answered then edit your message and add "[Solved]" to the subject line of the original post, and cast an approval vote to the one or several answers that really helped you.
If you are posting source code with your question, place it inside <pre></pre> tags. We advise you also check the "Encode "<" (and other HTML) characters when pasting" checkbox before pasting anything inside the PRE block, and make sure "Use HTML in this post" check box is checked.
Be courteous and DON'T SHOUT. Everyone here helps because they enjoy helping others, not because it's their job.
Please do not post links to your question into an unrelated forum such as the lounge. It will be deleted. Likewise, do not post the same question in more than one forum.
Do not be abusive, offensive, inappropriate or harass anyone on the boards. Doing so will get you kicked off and banned. Play nice.
If you have a school or university assignment, assume that your teacher or lecturer is also reading these forums.
No advertising or soliciting.
We reserve the right to move your posts to a more appropriate forum or to delete anything deemed inappropriate or illegal.
I did write to them, they said that the template is saved in RAM. So I do I retrieve it from the RAM buffer and save to database or file. If you have any idea please let me know.
Hoping to hear from you.
It is not really possible to tell if it's encrypted since, if it is done properly, there is not information in the file about the encryption method or keys. And a file is just a stream of bytes, so an encrypted file looks just the same as an unencrypted one.
I have a grid with empid's now if a person selects 2 grid by selecting checkboxes and click on download button 2 files should be offered to download.
I know that we can create a file and can send the location of the physical file.
But is there a way i can stream the files
public ActionResult GetFile()
var theStream = new Memorystream();
// create your file and add to memorystream or open a filestream instead.
returnnew FileStreamResult(theStream, string appropriateContentType);
Hello. I am using an ActiveX plugin (which is freely available) in .Net to play videos. Now whenever I switch from Code View to Designer View, Visual Studio 2010 crashes and restarts itself. I have tried to start the VS2010 as an administrator but in vain. What could be wrong and what could I try to prevent this? Thanks for any pointer.
This world is going to explode due to international politics, SOON.
From the point of view of that ActiveX control, its use on a form may look like "run-time" instead of "design-time".
In your code (constructor of the form, InitializeComponent), determine run-time/design-time and set some properties of that control accordingly (is there an Enabled property or something like that?).
public Type t;
return s.GetHashCode() ^ t.GetHashCode();
publicoverridebool Equals(object obj)
_Key o = obj as _Key;
if (o == null)
if (s == o.s && t == o.t)
and it yielded 60ms. Seems kinda pricey still. Compared to the Type key alone (20ms).
EDIT: tried something else... made the key an int and called GetHashCode() on the object to get the key. That knocked it down to 40ms.
EDIT #2: tried just returning the GetHashCode() on one of the members. Type = 50ms, string = 50ms.
Not really sure of a better way to implement GetHashCode().
It's really that simple. I know that's only 1 key, so my mileage may vary with a bunch of keys. I tried that same thing with various types to get the benchmarks I originally posted.
HOWEVER, I had a brilliant break through haha. Would something like this work?
Now, instead of overriding the GetHashCode and IsEquals, I just have a method:
public int GetKey(string s, Type t)
return s.GetHashCode() ^ t.GetHashCode();
whenever I want to insert a new object, I call GetKey() on it and use that as the key?
As I'm typing this, I'm beginning to poke holes in this idea... there would be no way to retrieve the string and type as I would just be keying off the hash code.
I'm also wondering if it would be possible to get two s and t combinations that produce the same key? Theoretically, I'm assuming the .net hash functions are strong. Although since I wouldn't be inserting the _Key struct into the list (and thus not override the IsEqual(), the dictionary wouldn't know for sure it was grabbing the right one...
If I do it "right" and insert the _Key, that's 60ms... better then 120ms or 590ms I guess.
It will probably be difficult to beat the inbuilt hash code functions for the general case
however there might be something about your specific data that you can exploit to make a stronger hash function
Example: If you know the first 4 chars of your strings are nearly always unique, you could just turn those into the 32 bit hash. This would save .NET framework from hashing the entire string so it will be faster.
It will also be stronger because you used knowledge specific to your data (Eg, the first 4 chars are enough)
If there are any features of your keys like above you can exploit. The chances of doing better than the inbuilt stuff will be much better
Yes, I was running in debug with the debugger attached. I understand it is a trivial / not full scope test. However, I did the same test on all the various types I mentioned to get a *rough* idea of the differences before I implemented the real thing.
I think seeing that an int was 10ms and a struct was 590ms is pretty indicative the struct is not a good solution (without overriding the IsEquals and GetHashCode methods).
I did try hack in the _Key struct with the overridden IsEquals and GetHashCode methods into my real test application & class that does a lot with the values. I did not use the int key hacky thing I was questioning as that wouldn't work.
My original dictionary took 110ms to run 1M iterations with the debugger attached and 3 items in the dictionary in the real application. Switching it to _Key and properly initializing the struct and the real hash code method bumped it up to 140ms to 150ms. So it actually added 30ms to 40ms of overhead which is what my trivial benchmarks kinda showed it would with 1M iterations.
FYI: Just for fun, I tried commenting out the IsEquals and GetHashCode overrides and it slowed to a crawl @ 1390ms! Wow. That is a lot more then I thought it would.
Last Visit: 31-Dec-99 18:00 Last Update: 22-Aug-14 0:45