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?
Dictionary<int, string=""> dict;
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<type, someclass=""> 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.
I have an existing .NET application which is making use of RAPI.dll till date to sync data on windows mobile. It works in the following way.
On my .NET windows based application I have option to sync mobile. When I click on that option, my app connects to database fetches records and creates a .DAT file which will then be added to mobile with the help of RAPI.dll.
Now I was asked to make use of Microsoft Sync framework as part of architectural changes within the project, as it been used in other areas of the project. So Im just wondering to know how to get the similar functionality what we were having with RAPI.dll in our project.
They look like GUIDs (they are formatted that way, but of course one can format any old garbage like that so you can't really be sure what they are). So there might not be any way to decode them. Perhaps, and this is just speculation, the strings are stored in a table and associated with a GUID when first encountered. That would mean you can't really do anything without access to that table. That's the sort of thing that's done to prevent whatever it is you want to do.
On the other hand, on the right side there are only 11-digit numbers. For 11-digit numbers, some 35 bits are sufficient (even when you encode it as ASCII characters, 88 bits are enough). If the process of generating the Guid uses that 11-digit number only (and nothing else) as an input, then a reversal of the process could be theoretically possible: no information need to be lost during that process. But that's surely not easy to find out how they did it.