.net

Is there already a comparison-interface in the framework ...

which is equivalent to interface ISomeKindOfCompare<T> { bool Matches(T item); } I know IComparer and IEqualityComparer and so on, but that's not what I am looking for. ...

Serving an Image stored in a database on an aspx page

I'm pulling back an image that is stored in a column in a SQL server database. I need to serve this up on an aspx page. How would I do that? ...

Semaphore.WaitOne/Release vs Monitor.Pulse/Wait

For me now it looks like functionally Semaphore.WaitOne/Release is equal to Monitor.Wait/Pulse. Skipping interprocess capabilities, speed (yes, Monitor is managed) other nonfunctional differences, what is real difference then? ...

How can I edit the "Public Key or Token" field of the Manifest embedded in a DLL or EXE file?

I'm trying to resolve the following problem: [.Net 2.0, CLR 2.5.something, 64 bit machine, all DLLs and EXEs appear compiled for "Any CPU" according to corflags ] I maintain a legacy application which uses a 3rd party DLL. Out of the blue (as far as I can tell) the functionality depending on the DLL stopped working on one of the mach...

What Replaces Code Access Security in .net

With the demise of Code Access Security, how do we restrict access to a DLL in .Net framework 4.0? Specifically, we have a project with a UI layer and a business layer. The UI layer tells the business layer who the user is. What we are trying to stop is any dll other than the UI layer calling the business layer and saying "Hi I am Joe"...

How i can change <s:Envelope to <SOAP-ENV:Envelope if i use wcf

Hi, i have an, i hope it is an simple, problem with wcf and the soap xml response of my service. How i can change i use .net 4.0, c#, basicHttpBinding and messagecontracts thanks in advance br waldi ...

Entity Framework. How to add object to collection in Unchanged state.

How to add object to a collection so that after .SaveChanges() it hasn't inserted/updated? ...

Load SOS extension for debugging

I'm trying to load SOS extension in visual studio 2010 (.Net framework 4) in a vb.net app without success. First i found the following article suggesting that I type "!load sos" in the immidiate window. It resulted in the following error message: Error during command: extension C:\Windows\Microsoft.NET\Framework64\v4.0.30319\sos.dll co...

Is there an interface wrapper around the Task Parallel Library so that I can swap it out for unit testing?

I asked this question a while ago. I now know it is a Bad Idea and that encapsulating the scheduling and running of tasks should be abstracted so that one can pass in a synchronous scheduler from the unit tests. I've currently got code that uses the Task Parallel Library (TPL) and I'd like to inject something like ITaskScheduler into ...

Updating a DLL in the GAC

I have an API DLL that several third party applications reference. Some of these applications want things two ways in terms of updates. 1) I want the latest stuff 2) Don't update my direct binaries that often There has been the thought of moving the DLL into the GAC and writing another DLL that is simply the wrapper for the DLL in th...

How to handle exceptions occured in the delegate target.

Hi, I have a delegate which points to 3 different methods. These methods are added in its invocation list. What is second method throws an exception??? I still need to execute the third method. I think one alternative is below mentioned code public delegate void MethodHandler(); A oa = new A(); B ob =...

How should I compare values in two lists?

I have two lists List 01 => { A, B, C, D, E } List 02 => { F, F, F, F, E } I need to check if one element of List 02 exists in List 01, so the following should be false. List 01 => { A, B, C, D, E } List 02 => { F, F, F, F, F } // no element matches And here it should be true. List 01 => { A, B, C, D, E } List 02 => { F, F, F, F, ...

Strange DateTime.ToString behavior

I have the following line of code inside of a function: String value = endDate.Value.ToString(dateFormatStr); //endDate is a DateTime? object (returned from a LINQ to SQL query). In the particular instance I am experiencing odd behavior, the value of endDate is {10/2/2010 12:00:00 AM}. Here's my results: dateFormatStr="d" => value="1...

How can i see execute command in Entity FrameWork ?

i try to use erpCtx.Executecommand but i doesn't have method of executecommand. i think that i must add dll in Reference to show executeCommand? i need : int rowsAffected = engCtx.ExecuteCommand("insert into ENG_MAINWP Values({0},{1},{2},{3})", engArray[0], engArray1, engArray[2], engArray[3]); ...

Prevent or handle time out with XmlReader.Create(uri)

Sometimes I am getting a time out exception when reading an XML via a URL. Is there something I can do to prevent this, or is this a problem with the remote server? Below is my simple code: XmlDocument doc = new XmlDocument(); doc.Load(XmlReader.Create(this.RssUrl)); I cam across a post that says KeepAlive may help, but I do not know ...

Is this combination of ConcurrentDictionary and ConcurrentQueue thread-safe?

I'm using the ConcurrentDictionary and ConcurrentQueue classes from .NET 4 in the following code. Is this code thread-safe? If not, how can I make it thread-safe? public class Page { public string Name {get; set; } } public class PageQueue { private ConcurrentDictionary<int, ConcurrentQueue<Page>> pages = new Concurren...

How can I clear the cache of the workflow designer (where does it cache things) ?

Every time I change some InArgument of my CodeActivity or an activity defined as an XOML, it takes a couple of restarts of Visual Studio and deleting all the traces of my project's dll on the hard drive (not sure which part actually works) until the changes are reflected in the workflow designer. Is there some way to clear the cache of ...

Registry security settings

I’m trying to access a certain bit of the registry however it keeps returning null when i try to open it. However i know the location is correct because i can navigate to it in reedit. here’s my line of code for trying to access it. Microsoft.Win32.RegistryKey RK = Microsoft.Win32.Registry.LocalMachine.OpenSubK("Software\\Microsoft\\W...

DataTable type of array binding in cf.net

I would like to make a (very lightweight) 2-way binding datastore. Values must be accessed via names. I was thinking of using 2 arrays: public class MyBindingDatastore{ public string[] _names = new string[]{"Field1", "Field2", "Field3"} public object[] _values = new object[]{ DateTime.Now, "MyValue", 1} } First array is used t...

How would I capture all keystrokes from a windows service?

I saw some software the other day that logs all keystrokes that are typed on the machine that it is installed on. How would I go about writing something like this using a .NET Windows service? ...