.net

Is there a standard way of implementing a proprietary connection pool in .net?

Is there a standard connection pooling model (or API) similar to that used by the data providers in .net that I could use to implement my own connection pool? I ask because I have a requirement to implement my own connection pool to a proprietary TCP/IP device that we use in a web service. The current problem is that there are lot of co...

Is it possible to start / stop an application pool or website in IIS programatically?

I'm trying to find a way to stop, start, restart/recycle websites and application pools from within a web interface on the same server. Ideally this would be something I could do with .Net without having to execute shell commands. (I see other related quesitons have been asked but I don't want to do this from the command line unless th...

How to use reflector to view the implementation of .NET library functions

I tried to see the implementation of [MethodImpl(MethodImplOptions.InternalCall)] public extern int get_Length(); fucntion, which in turn is Length property of string. But reflector gave me the following error "The member is not loaded or may be hidden due to your visibility settings" However the member is loaded and the visibility set...

Writing a Color sARGB array to a WriteableBitmap

I have an two-dimensioanl array of sARGB colors (System.Windows.Media.Color) describing what I want to write in a WritableBitmap. The array is the same width and height than the expected bitmap. The problem is that, as long as I can see, the WritePixels Method of the WritableBitmap expects an array of integers. How do I convert my col...

How to Read Custom XML from the app.config ?

I want to read the custom XML section from the app.config of a C# windows service. How do I go about it? The XML is below: <Books> <Book name="name1" title="title1"/> <Book name="name2" title="title2"/> </Books> ...

In log4net, should be output for a named logger also go to the default appender?

If I have log4net configured as below <root> <level value="INFO" /> <appender-ref ref="RollingFileAppender" /> </root> <logger name="MyNamespace.MyClass"> <level value="INFO" /> <appender-ref ref="AdoNetAppender" /> </logger> I would like the output from the named class to end up only in the sql database (via the adoNetA...

How do I access ARP-protocol information through .NET?

I am trying to figure out what devices are online and offline in our LAN. I've seen many programs doing a kind of graphical network overview, presenting LAN IP and MAC addresses. I would like to know if and how those (ARP?) information can be pulled from C#/.NET ? Any sample code snippets/links would be appreciated. ...

How to set clipboard to copy files?

In my application, I allow the user to select items that correspond to files on a disk. When the user presses Ctrl+C, I want the file to be sent to the clipboard, where the user can then paste the file somewhere else. I want to implement it in a way so that the user can copy, but not paste inside my application. The user is then free to...

View-Specific Formatting Code in ASP.net MVC

Just some architectural question: I use ASP.net MVC and exclusively rely on Strongly-Typed Views with View Model Classes. As presentation is the job of the View, these Classes do not only contain some fields, but also some formatting functions, e.g., // The ViewModel contains a List<Comment> which the view.aspx iterates // through, cal...

32bit 64bit referenced library

Hi, I am developing an application that has two DLLs one is a 32bit version another is 64bit version, Client is 32bit Server is 64bit My question is is there a way I can say use the 32bit dll when doing Debug/Release and use 64bit dll when I perform a publish. I realize I can solve this problem using NAnt or MSBuild but was wonderin...

How to make custom WCF error handler return JSON response with non-OK http code?

I'm implementing a RESTful web service using WCF and the WebHttpBinding. Currently I'm working on the error handling logic, implementing a custom error handler (IErrorHandler); the aim is to have it catch any uncaught exceptions thrown by operations and then return a JSON error object (including say an error code and error message - e.g....

Ninject: Howto setup Bindings based upon Dependency Chain

Ok Dependency Ninja's, here's one for you... I want to change the way Ninject builds a dependency based upon the type I'm requesting from the Kernel. I have a DbConnectionFactory class with the following constructors: public DbConnectionFactory() : this(MyDatabase.ConnectionString) { } public DbConnectionFacto...

How to ensure all changes in every controls applied to the DataSet before the data save to the database ?

When I develop using Delphi I always call DataSet.CheckBrowseMode() to allow bound controls to apply its pending changes to the DataSet. I've been looking for similar way in .NET I've tried // When the user press Ctrl-S // Apply any pending edit this.TheDataBindingSource.CurrencyManager.EndCurrentEdit(); // then save the data this.S...

Why does Console.Out.WriteLine exist?

Actually the question should be why does Console.WriteLine exist just to be a wrapper for Console.Out.WriteLine I found this little method using intellisense, then opened .NET reflector and 'decompiled' the code for the Console.WriteLine method and found this: public static void WriteLine(string value) { Out.WriteLine(value); } S...

GC.AddMemoryPressure question

I've read about it on msdn and on CLR via c#. My main question about it is the following: let's imagine we have a 2Mb unmanaged HBITMAP allocated and a 8 bytes managed bitmap pointing to it. What's the point of telling the GC about it with AddMemoryPressure if it is never going to be able to make anything about the object, as it is allo...

GC.Collect()

Ok, I've read a couple of topics about it, but here it goes. Let's imagine I have an application where basically every now and then I will click on a button, a lot of things will happen for a couple of minutes, and then it'll stay idle possible for another hour, or maybe just 1 minute. Wouldn't just after that whole ended a good situatio...

C# 2.0 generics: How to create an Action object with zero parameters

First of all, I'm using VS2005 and C# 2.0. I'm trying to set a combobox' Text property from inside the SelectedIndexChanged event. From another thread here on StackOverflow this was proposed done the following way: BeginInvoke(new Action(() => someCombobox.Text = "x" )); Now, first of all this returns a compiler error for me. I belie...

One to one relationships with Subsonic

How can you create a one to one relationship in Subsonic? For example, I have my table called Readings and each Reading has only one book, however Subsonic returns an IQueryable of books. I want it to return only one book. Thanks. ...

Google search API versus MS SQL Server Full Text Indexing?

We are working on websites for our clients and we want to adopt a search solution that can be easily reused. Which one should we go after ? Should we use Google Search API or should we use MS Sql Server Full Text Indexing and the CONTAINS & FREETEXT predicates ? ...

NameValueSectionHandler - can i use this section type for writing back to the application config file ?

back to the topic of why didn't .net provide a simple (i don't want to implement "ConfigurationSection" "ConfigurationElement" "ConfigurationProperty" for 2 values) way to write values back into application config files... (and i don't want to use 'user' app config) i want to write to the app.config values, i tired the above method of k...