.net

Ah getting so confused with service layers

Hi Service layers and repository seem so simple on paper but I am getting myself confused. So here is what I am confused about. I have a service layer for my PayPal service layer with validation logic relating to my PayPal stuff and methods that connect to my paypal repository and return results (and do more logic if needed). Now on m...

AccessViolationException in COM control in .NET app

I'm working for a client that has a VB6 app in the migration process to .NET. Currently they have a .NET shell, but host some old VB6 controls in .NET. There's an error I stumbled upon is logs that happens when they in .NET asynchronously pull some data from the database, and then forward that data to a COM component to display it: The...

Remove map move event by user

How I can handle map move event by user? (Down left mouse button and mouse move) My goal is remove all users event, which can modification map view. I using Bing Silverlight Map Control. ...

Creating a user interface for monitoring and interacting with a running windows service

I need to run a bunch of pluggable processes in a windows service on my server and want to create a user interface that allows me to interact with each of the plugins in use by the service. What is the most common method (or methods) for communication between a user interface and a long-running windows service? I am thinking of providin...

How to store a HashTable in the usersettings?

Hello, In .NET you can select a hashtable as type for a usersetting. However when I save it and retrieve it in this way, it doesnt seem to have saved it at all. Hashtable t = new Hashtable(); t.Add(1,"Foo"); t.Add(2,"Bar"); Properties.Settings.Default.Setting = t; Properties.Settings.Default.Save(); if(Properties.Settings.Default.Sett...

Is it possible to extend the set of persistent collections recognized by NHibernate?

Dear ladies and sirs. Suppose I wish to inherit PersistentGenericBag, so that the actual type of my collection property is my custom type, which derives from PersistentGenericBag. I see two possible ways to achieve this: Introduce a new XML keyword, like mybag and somehow register my collection type with NHibernate to associated it w...

Is this is an ExpressionTrees bug? #3

Expressions class should be more accurate while searching for user-defined operators? sealed class Foo { // just the private static method! private static int op_Implicit() { return 1; } public static implicit operator int(Foo foo) { return 2; } } public class Program { private static void Main() { var param = Expression...

Is this is an ExpressionTrees bug? #4

This is not "close to real" situation, but it shows that Expressions API doesn't look for operators in the destination type of conversion if it founds the suitable operator in the source type. sealed class Foo { public static explicit operator Bar(Foo foo) { return null; } } sealed class Bar { public static implicit operator Bar(Fo...

How to synchronize asynchronous methods?

var arguments = new double[] { 1d, 2d, 3d }; var result = arguments.Select(arg => Math.Sqrt(arg)); Now imagine a asynchronous method instead of Math.Sqrt (i'm not sure the method below is a true async method, but it behaves approximately like one) public void BeginSqrt(Action<double> callback, double argument) { Thread.Sleep(100);...

Fastest way to list all files + dirs in .NET

I know how to use the DirectoryInfo.GetFiles(), but I do not think this is the fastest way to go. These "FileInfo" objects seem a little bit big... Why do I need it? Well, I tried to achieve my search tool with WDS, but I give up. The OleDB connection is horrible, strange errors without any explanation. So what I am going to do is: Reb...

Does AutoResetEvent.WaitOne() frees a slot in the thread pool?

I am trying to synchronize an asynchronous method. The main advantage of the async version is that it frees a slot in the thread pool. I would like to keep this advantage in my sync version. When I use AutoResetEvent.WaitOne() it is equivalent to a Thread.Sleep() in terms of thread pool usage? ...

Safety of Interlock.Exchange and Garbage Collection

I have an object that I am accessing from two threads. One thread calls a long-running member function on the object that returns a value. The second thread updates the object used to produce that value. I if I call Interlock.Exchange to replace the object from the second thread while the first thread is executing: 1. Will the old th...

.NET strings and reference type parameters

I was wondering if any one could explain this code to me... public void SomeMethod() { StringBuilder sb = new StringBuilder(); AppendFoo(sb); String foo = sb.ToString(); // foo is "foo" String s = String.Empty; AppendBar(s); String bar = s; // bar is empty } public void AppendFoo(StringBuilder x) { x.Appen...

How do I remove the icon and title from a WPF Window but display it in the taskbar?

I'm trying to create a WPF window, which has no icon and no title displayed in the titlebar. I already found some examples how the icon can be removed (for example here), but all these solutions work if I'm debugging the application in Visual Studio but they don't work when I'm just running the executable. I would also like the title n...

Preventing GetType from throwing exceptions on internal types

Is there any way to prevent o.GetType() from throwing an exception when called on an object whose type is internal and resides in another assembly? I am wrapping a COM based API inside a .Net assembly so that it is possible to benefit from more native .Net integration (Collection interfaces, streams, exceptions etc.). The collections t...

How do i use TLBIMP.EXE ?

I've found it in my visual studio folder, but when i open it it simply loads and closes instantly. is that the right way to reach to it's functionalities ? ...

Cancellable Sort in .NET ?

Hi I'm using ListView in VirtualMode to show extremely big number of rows, millions of rows. The data of the rows stored in a Generic List. Now i want implement a sort feature, that will sort the List by some Comparer. The problem is that for now, an average single sort takes around 30 seconds, and during this time the user cannot do ...

How to get the maximum outbound requests when parellellizing asynchronous calls?

Analysing the code below in action through Fiddler, I realized that using Parallel Extensions I can get at maximum 2 outbound requests: new string[] { "http://stackoverflow.com", "http://superuser.com", "http://serverfault.com", "http://stackexchange.com" } .AsParallel() .Select(a => Http...

MSBuild Extension Pack

Is there a way to use the MSBuild Extension Pack with a "local" reference that doesn't require you to run the installer? In other words, can you store the targets in a solution items folder so that every developer doesn't have to install it? ...

Setting headless property in .net

In java you can set a "headless" flag to true to reconcile the differences between a headless server environment and your desktop development environment. System.setProperty("java.awt.headless", "true"); So whenever you try to do an operation not supported in a headless environment the VM throws an Exception What are the settings or ...