.net

Weird behaviour of a deserialized class

I've got a huge XML file that's being deserialized by XmlSerializer in an XSD-generated class structure. Everything used to work just fine, but now a weird thing started happening. Sometimes (50% of runs) a field of a certain object of a class that's deep in the class tree just changes to a certain value of the same field of a different ...

How can i find which DIrectX version install on my system through code

How can i find the current install version of directx on my system using code(C#). ...

Decimal Cut problem

Is it possible to cut decimal, and not round it. Like this. decimal number = 12.159m; How can I easily get 12.15 from number and not 12.16? Is there an easy way or is the string manipulation the only way? ...

Can you verify a mock object if you don't have its Moq-wrapper?

Can anyone explain to me how to verify mocks if you don't have their Moq-wrapper? MockFactory.Verify() won't do. I want to be able to verify the mocks explicitly and mocks should be created using mockfactory! Please send in your comments. ...

Sync Framework Handling ClientInsert ServerInsert Conflict

Hi, I have a application that uses LocalDataCache to synchronise a SQL Server 2008 Express database to a client database (.sdf file). This works great and I am now managing the conflicts. I am using this Microsoft resource as a guide: How to: Handle Data Conflicts and Errors The conflict I am particularly interested in is ConflictT...

Design Patterns in .NET

What good resources are out there for learning Design patterns in C# and the .NET Framework? ...

How to change the timeout on a .NET WebClient object.

I am trying to download a client's data to my local machine (programatically) and their webserver is very, very slow which is causing a timeout in my WebClient object. Here is my code: WebClient webClient = new WebClient(); webClient.Encoding = Encoding.UTF8; webClient.DownloadFile(downloadUrl, downloadFile); Is there a way to set a...

How to get Datagrid view cell value?

Using VB.NET How to get Datagridview cell value. I want to insert a Datagridcell value in the table, How to get datagridview cell value. Need vb.net code Help ...

Inject static property with StructureMap?

Hi all, is it possible inject static property, like I do below, because it does not work for me? public static IMerchantModule MerchantModule { get; set; } public RequestBaseValidationRules() { MerchantModule = ObjectFactory.GetInstance<IMerchantModule>(); } It works when I inject to non static property. Any ...

Unity IOC, AOP & Interface Interception

I've been playing around with Unity to do some AOP stuff, setting up via IOC like: ioc.RegisterType<ICustomerService, CustomerService>() .Configure<Interception>().SetInterceptorFor<ICustomerService>(new InterfaceInterceptor()); ... and then having an ICallHandler on the ICustomerService interface's methods. For teh time being i w...

Enable command binding for TextBlock

I am developing a WPF application, and have a TextBlock which I want to use command binding to trigger a command on when clicked. What's the best way to achieve this? The TextBlock-control does not have a Command property, but it does have a CommandManager. What is this? Can it be used for command bindings? I've seen many other contro...

Where does this permanent SQLExpress connectionstring come from (not web.config)?

Today I noticed that in my ConfigurationManager.ConnectionStrings the very first instance is .\SQLEXPRESS. I remembered explicitly removing this entry from my web.config so I checked again, but didn't find a thing. Then I did a search over my entire solution, not a single match. Where the hell is this connection string coming from and ho...

Is there a built-in way to replace the text of a link in a LinkLabel and have the other links automatically adjust so they stay on the same text?

In other words, if I have: var ll = new LinkLabel(); ll.Text = "Some links go here."; ll.Links.Add(0, 4); // Some ll.Links.Add(11, 2); // go Is there any method I can call to replace the text of the "Some" link with something else while keeping the "go" link the same. I only want to know if there is a built-in method. This is not h...

Are all Serializable classes valid for WCF methods parameters and/or Data Contract members?

I am in the process of porting some .net remoting code to WCF. Can I safely assume that all classes that are Serializable and works as .remoting method parameters will work with WCF using the binary message encode? If not is there a “rule of thumb” that I can use to estimate what problems I will hit? ...

TCP Server not reading from socket untill objects disposed

Hi, Please excuse my choice of wording and/or mixup of terms, I am a dummy when it comes to socket programming. I am trying to connect to a TCP server, write a message and process a response. I use the following code: Dim tcpClient As Sockets.TcpClient = New TcpClient() tcpClient.Connect(hostname, 9080) Dim networkStream As NetworkSt...

How to ensure that no item is selected in databound ListBox?

OK, this must be a duplicate question, but I cannot find the answer: I have a listbox that is databound to a Collection. By default Items[0] is selected. How can I prevent this in order to ensure that the SelectionChanged event is raised any time I click a ListBoxItem? EDIT: I had already dismissed the SelectedIndex=-1 route, but I trie...

.Net Remoting - Serialisation of Delegates

I have written a custom remoting formatter sink for an established application. The formatter appears to work for most cases until I try to use it to call a remote method to which I pass a call-back to a CAO. At this point I get a SerializationException indicating that I am trying to serialise the CAO, which is obviously not what I want ...

Is there any circumstance in which calling EnterWriteLock on a ReaderWriterLockSlim should enter a Read lock instead?

I have a seemingly very simple case where I'm using System.Threading.ReaderWriterLockSlim in the 3.5 version of the .NET Framework. I first declare one, as shown here: I put a break point right before the lock is acquired and took a screen shot so you can see (in the watch window) that there are currently no locks held: Then, ...

Suggestion/Opinion on Reverse IP look up for Anonymour proxies

Sometimes it is not possible to find if user is using Anonymous proxy. So i came up with some ideas: Get IP of client, do reverse check and check if it returns a hostname and also get number of any websites hosted on same ip then it could be a proxy connection assuming it is website hosting provider ip. Store ips of hosting providers w...

How to call NetUserModalsGet() from C#.NET?

EDIT: followup at http://stackoverflow.com/questions/1791377/netusermodalsget-returns-strings-incorrectly-for-c-net I'm struggling with the DLL declarations for this function: NET_API_STATUS NetUserModalsGet( __in LPCWSTR servername, __in DWORD level, __out LPBYTE *bufptr ); (Reference: http://msdn.microsoft.com/en-us/libr...