.net

How do I translate this code into an expression tree?

I have a hashing method whose operations depend on input to the function. Profiling the program has shown that too much time is spent evaluating this hash method. I want to try changing it into an expression tree, so the inner loop checks can be done once. Hopefully it will be faster, but I'll learn about expression trees either way. He...

Generating Admin Interfaces in ASP.NET or ASP.NET MVC

Is there a Django-like admin interface generator for ASP.NET or ASP.NET MVC? If not, are there any tools that could assist in creating one? ...

Naming conventions - in which namespace do subclasses go?

Hypothetically, if I have: Contoso.App.People.SecurityGuard : Contoso.App.People.Person And I then build this class and ship it as a core lib. If I then consume this library in, say, a mobile client app and make a: NightDeskGuard : Contoso.App.People.SecurityGuard In which namespace would the new class go? Contoso.App.Mobile.Peopl...

How does the .NET Runtime Locate Non Strong-Named' Assemblies?

We have different versions of non strong-named assemblies, and no binding redirects/probing paths to them in app.exe.config. For example, MyDll (1.0.0.0_null_neutral) and MyDll (2.0.0.0_null_neutral). Relative to app.exe, these assemblies are stored in LAC\MyDll_1.0.0.0_null_neutral and LAC\MyDll_2.0.0.0_null_neutral. My understanding i...

What is System.ServiceModel.Diagnostics.CallbackException and why can't I handle it?

In my WCF client class I'm handling the Faulted() event so that if the remote service throws an exception and faults the channel I can still at least shut it down gracefully. Here's my code: protected void RemoteDataRetriever_Faulted(object sender, EventArgs e) { (sender as ICommunicationObject).Abort(); this.Dispose(); thro...

How would I use the SecurityPermissionAttribute correctly?

In an old project I came across the following assembly attribute: [assembly: SecurityPermissionAttribute(SecurityAction.RequestMinimum, Execution = true)] I understand that this attribute instructs the clr to not load this dll if the required permissions aren't available. Is it a good practice to include such declarations in your proj...

How can I represent state of method execution in base class without affecting the implementation in the derived classes?

I'm trying to create an abstract class, defining an abstract method, that is to be derived from other classes that implements some specific behavior in the abstract method. I want the abstract class to contain some kind of state information that represents however the implementation in the derived classes exited without errors, but I wan...

Class design: clearing state

I am designing a class library which will be used like this: Engine eng = new Engine(); eng.AddPart(part).AddPart(otherPart).Run(); The problem with the class is that the parts are kept by the engine so if you want Run it with some other parts you will need to remove the ones that you have already added. There are several possible ...

Why doesn't Dictionary<TKey, TValue> have an IEnumerable<KeyValuePair<TKey, TValue>> ctor?

Okay - so I know it's simple to build a factory method that provides the functionality; but given that Dictionary<TKey, TValue> is IEnumerable<KeyValuePair<TKey, TValue>>, shouldn't it have a Ctor equivalent to, for example, List<T>'s ctor(IEnumerable<T> range)? It's even sillier given that it provides a Ctor that takes an IDictionary<T...

how to clear GridView

I have 3 GridViews in my page. Using the SelectedIndexChanged event I put GridView2 and GridView3 data in GridView1 but when I restart my application GridView1 data is still persisted in browser. I used a session variable to store the data. How can I clear GridView1 ...

Code Review: OutOfMemoryException problem

I keep getting a 'System.OutOfMemoryException' thrown at the code below. I can't figure out where the memory leak is and it would be a great help if someone could explain what I am doing wrong. Thanks! lock ((_tabs)) { System.IO.StreamReader sr = null; System.IO.MemoryStream ms = null; try { Type[] t = { typeof(t...

How can I get a NullReferenceException in this code sample?

??? o = new ???(); Console.WriteLine("ToString() -> " + o.ToString() ); //<--- Prints 'ToString() -> ' Console.WriteLine("GetType() -> " + o.GetType()); //<--- NullReferenceException Output: ToString() -> Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object. at System.Object.GetT...

How to persist anonymous types instances through NHibernate?

Instinctively, I would say that this is impossible, as NHibernate needs to know some mapping information on how to persist a given type. Thus, I encountered some situations in which I could use such a feature. For instance, through a named query or something like so. On the other hand, using a named query would require me to make an addi...

SQL Pivot and formatting Grid

I used pivot to get data in format Store department Employee Q1 Q2 Q3 ---------------------------------------------------------- abc d1 u1 1 Null Null abc d1 u1 Null 3 Null abc d1 u1 Null Null 2 abc ...

Native .NET version of Rsync for commercial application available?

Currently we are evaluating whether it is possible to provide rsync support to an application we sell. I did a Google search and found some references: "Native Window version of rsync" - A discussion about an implementation but without any code. "Has anyone wrapped the rsync algorithm in C#-callable package?" - A discussion that links...

Find a variable with a given value in VS2008

I have an instance variable with several members, many of which have their own members and so on. Using the debugger and watch variables, I found a string variable with a specific value that I need by diving into this variable's members. However, after spending some time on other things and coming back to this, I am now unable to find w...

What's the memory cost of a DataSet vs other .Net Collection classes?

In our now-not-so-modern n-tier application we make intesive use of DataSets and we are evaluating the change to other lighter objects (i.e. collections of typified objects). Is there any reference document about how much can we gain in memory consumption by doing that? ...

How to install Microsoft.VisualStudio.Shell.dll on Client Computer

I am dealing with some code that won't install on client machines (NOT running Visual Studio) because is makes reference to VSConstants.S_OK, which is in Microsoft.VisualStudio.Shell.dll. Is there a redistributable that includes this, or do I need to have the code updated to use a different constant. ...

Limiting Access to a DLL in .NET

I write in-house software for a company. I always want to leverage OOP techniques as best as I can. In this thinking, I want to create a Data Access Layer (DAL) isolated in its own .DLL. What can I do to limit the access of the DAL DLL to only my business logic layer DLL? The last thing I need is someone in the company with a littl...

Subscription Notification Service using SQL or .net?

I need some advice. I have to create a subscription notification service for my system. I need something that will be flexible where I can set some parameters to send out notifications on certain days (before a subscription is expired) and to set accounts to expired. I need something to run in the background that will send out these noti...