.net

Queue questions

In our application we have a Queue which is defined as the following: private static Queue RawQ = new Queue(); Then two different types of objects are put onto the Queue, one are objects from a class (class A) and one are objects from a struct (struct B). When we process the data from the Queue, we use typeof to check the item from t...

Minimize the number of cross-core context switches

I was experimenting a lot with application profiling lately (using Visual Studio Performance Wizard). While working with Concurrency indicators, I've noticed the fact that when the application runs with multiple threads (both background and foreground) the cross-core context switch rate is quite high. Knowing that generally a large numb...

Error 10061 while trying to connect to my own computer

I'm just testing out some basic networking code written in Visual C++. I have a client app and a server app that don't do anything fancy, since I'm just testing - basically, the client sends ASCII-encoded strings to the server and the server sends it back all in caps. Everything works fine when I run both programs on my computer, IF I s...

Understanding DLL Versioning in .NET 1.1 versus .NET 3.5

Is dll versioning implemented differently in .NET 1.1 versus .NET 3.5? It seems I can mix and match older and new versions of dependent dll's in deployed applications using .NET 1.1 but leads to problems when doing the same mixing a matching with dll's running in deployed .NET 3.5 applications. ...

ParamArray Not Working With COM

I have a Class Library that is exposed to COM like this: <ComClass(SomeClass.ClassId, SomeClass.InterfaceId, SomeClass.EventsId)> Public Class SomeClass Public Const ClassId As String = "GUID1" Public Const InterfaceId As String = "GUID2" Public Const EventsId As String = "GUID3" Public Sub SomeMethod(ByVal ParamArray ...

.NET Memory Leak

Hi, After running our stress testing on our ASP.NET application access to internal web services, our mid-tier server (where we host ASMX .NET 3.5 web services) showed close to 1GB of memory consumption. Upon the review of memory dump from mid-tier server, I have found over 1000 objects of Microsoft.Xml.Serialization.GeneratedAssembly.A...

AND Gate with delayed inputs in C#

I am trying to implement a boolean AND gate with multiple inputs. Each input has an integer identifying it. Input signals arrive randomly, and are stored at the gate (so it's not a pure AND gate, but one with delayed inputs). Only when all the input signals have arrived, does the gate fire. Note: 2 signals arriving at the same input do n...

Fast way of going from Excel to a DataSet or DataGridView

I have data that I'm taking from an Excel sheet with the ultimate goal of displaying in a DataGridView. Currently I am just going over the UsedRange of excel data and plugging it into a datagridview. This works fine, but can get bogged down when there 100+ rows of data. I have also toyed with going from excel into a dataset (using the ...

How to position a element (drop down menu item) exactly below the parent menu

I am trying to place a dropdown menu item below the parent menu. When u hover on the parent menu, the child dropdown menu item's visibility will turn visible. I positioned the child elements using position:absolute and using top and left. But when i change the resolution of the monitor the left and top alignment changes How to positi...

Calling managed code from unmanaged code in VS2010

Hi, I have an managed c# application that uses expression encoder 4 SDK, and thus requires .NET 4 and hence VS2010. I wish to startup and stop this application as an in process DLL. This article and demo on code project proved a very useful proof of principle http://www.codeproject.com/KB/mcpp/ijw_unmanaged.aspx The included demo wo...

MS SQL -- Okay for multiple users to connect/read/write to database from a web service (c#)?

Hello all, This is probably a simple one... Right now I have a working web service (programmed in c#) and it offers up two webmethods that either read or write data to a MS SQL database. What I want to know is this... Do I have to worry about errors when multiple users try to connect to, reading from, and writing to the database? Furth...

ERROR: Loading object was of wrong class

Hi All, I have an MVC/Nhibernate app that is giving me the below. [WrongClassException: Object with id: f7eab616-76b2-4602-8643-b4466e91a33f was not of the specified subclass: AgileThought.ERP.Domain.CRM.Client (loading object was of wrong class [AgileThought.ERP.Domain.HR.SalesRepresentative])] NHibernate.Loader.Loader.Instanc...

How to Cause an HttpModule to be Invoked Before the First Request?

I have several applications I am deploying to a .NET/IIS environment. For these applications I have registered an implementation of IHttpModule in the system.web/httpModules section of web.config. In my implementation of IHttpModule I have an Init() method which starts up some daemon threads and logs that the application has been start...

How can I call a method from within a LINQ expression?

I've my Model something maybe like this : public class Person { public virtual Guid ID { get; set; } public virtual string FirstName { get; set; } public virtual string LastName { get; set; } //this LazyList takes IQueryable<T> in constructor public virtual LazyList<Role> Roles { get; set;...

DataTable.Select using the IN operator

I've never found an elegant way to do this, so I'm wondering what methods other developers prefer (for performance, readability, etc). Is there a way to use the LIKE operator in the DataTable.Select() function, based on the results of a query to another DataTable. For example, in SQL Server, the syntax would be: Select SomeValue From...

Cell color of WPF DataGrid back to the default

I'm using buildin WPF DataGrid in .net 4. I can set the background of a DataGridCell programatically like below. DataGridCell dgc = this.GetCell(i, j); //GetCell is extension func dgc.Background = Brushes.LightGray; My question is, how can i remove the background color i set and back to the default? By "default" I mean the default t...

Popup Stays Open with StaysOpen = "False"

Hello All, I've created a WPF Popup with StaysOpen = "False". Nonetheless, it stays open if I click outside the Popup but still within the app's main window. (If I click outside the main window, then the Popup will properly close.) For this Popup, I have tried both Placement = "MousePoint" and Placement = "Mouse". I do believe that th...

Detect laptop lid closure and opening

Is it possible to detect when a laptop's lid is open or closed? From what I've read, this isn't possible, but SO has helped me with the impossible before. The only thing I've found that might be in the right direction is an MSDN blog post about IOCTLs needed to report power buttons. Is it possible to "sniff" these as the OS calls them...

VSTO Outlook: Creating a dynamic custom context menu for a mail item determined by subject line

Is it possible to add different items to a mail item custom context menu by inspecting the contents of the item? For instance, only add the item if the subject line contains "IMPORTANT". ...

Can you call a class member from within a PostSharp advice?

So I'm working with PostSharp to pull out boilerplate logging/exception handling code so that this: public void doSomething() { Logger.Write("Entered doSomething"); try { // code } catch (Exception ex) { ExceptionPolicy.HandleException(ex, "Errors"); } Logger.Write("Exited doSomething");...