.net

List columns in a SSIS Flat File Connection

I'm trying to produce a column 'start/length' spec document from a SSIS package that exports a DB table to a flat file. I have hit something of a brick wall in getting the Columns property from the ConnectionManager object that handles the flat file connection. I am able to get the Columns property, but I cannot do anything with it, as...

Creating a ToolBox component with design-time support using a UserControl

I have a UserControl for Windows Forms. How can I convert it to a component? What I want to do is, to add it to the VS toolbox, add it to form with drag and drop at design-time and change its Location and Dock properties using the Properties window. What should I look for to do this? I've created something similar before but it was a Co...

How to detect Windows Logon event ?

How do you detect Windows logon event? And how do you initiate a user logon from a Windows service? I'm trying to write a piece of code that will detect logon events and log another one automatically. ...

Monitor Windows Share

I am trying to monitor connections to a windows share using C#, I am pretty sure it’s possible since you can see people connected to you from Windows Console Manager. While I don't mind a solution using WMI I would prefer some alternate method. What I mean by connections is when someone opens a share on the PC being monitored or a file...

How to round decimal value up to nearest 0.05 value??

Is there any way to round up decimal value to its nearest 0.05 value in .Net? Ex: 7.125 -> 7.15 6.66 -> 6.7 If its now available can anyone provide me the algo? ...

is testing the public API enough for unit testing an API component?

Hi, My software (application) exposes an API (webservices) using httplistener. Is it from a unit test point of view enough to test the API functions through web requests? I ask this since I read that a best practice is to test only the public methods of a class. In this case I'm not testing public methods of a class but the public API ...

.NET FileInfo.LastWriteTime & FileInfo.LastAccessTime are wrong

When I call FileInfo(path).LastAccessTime or FileInfo(path).LastWriteTime on a file that is in the process of being written it returns the time that the file was created, not the last time it was written to (ie. now). Is there a way to get this information? Edit: To all the responses so far. I hadn't tried Refresh() but that does not ...

How do I use a 'foreign key' as criteria in a LINQ to Entities query?

I have a Departments table, which has a foreign key column to Sites, on Department.SiteId = Sites.SiteId. Now in my EF model, my Departments entity doesn't have a Siteid attribute, just a reference to Sites. How do I select, in a LINQ query, all departments with a specific SiteId? ...

Dynamic 'table' name in LINQ to entities

I need to select from varying levels of reporting department tables, i.e. Dept1, Dept2, Dept3, ect. [1] depending on which reporting level the user chooses. How can I dynamically express the 'table' to select from based on a given string parameter, which is the table name? [1] Easy points (lets talk) for anyone that can help me out of ...

How to identify the video frame size

i.e. the size and width of a video in different formats ( at least the common ones .avi, .mpg, .mpeg, .mov, .asf ) etc. preferably using .net code or code usable from .net ? UPDATE - 1) any way to get the timestamp of the time the video was taken - something akin to exif info for digital pictures, this only needs to work for my video ...

How do you pronounce WPF?

Hi, I'm not a native English speaker, hence sometimes I'm in doubts how to pronounce an english acronym properly. How do you say WPF (Windows Presentation Foundation)? Thanks. ...

How to diagnose an error with W3WP.exe in a WCF service hosted by IIS7

Hi, I've a .net WCF service hosted on an application server with windows 2008/IIS 7.0. I see following error message in the event log: Faulting application w3wp.exe, version 7.0.6001.18000, time stamp 0x47919413, faulting module ntdll.dll, version 6.0.6001.18000, timestamp 0x4791a7a6, exception code 0xc00000374, fault offset 0x000b015d...

Cleanup user input library .NET

Is there a .Net library which everyone uses to validate/cleanup user input from website. It seems like there are a lot of posts explaining which regex people use and when. While I do like to reinvent the wheel quite frequently I draw the line at user input. Mostly I am not worried about SQL injection, but rather am concerned about html...

Polymorphism with Dictionaries

I've a base type from which 3 different objects are inherited. Lets call the base object B, and inherited ones X, Y, and Z. Now I've dictionaries with an int as key and respectively X, Y, Z as value. I've a control that will need to do lookups in one and only one of the specific dictionaries to draw itself but to be able to work with al...

CUDA global memory deallocation issues in .NET

I have a class (see example bellow) which acts as a .NET wrapper for a CUDA memory structure, allocated using cudaMalloc() and referenced using a member field of type IntPtr. (The class uses DllImport of a native C DLL which wraps various CUDA functionality.) The dispose methods checks if the pointer is IntPtr.Zero and if not calls cuda...

Chaining databound LINQ queries in LINQ to DataSet

I am trying to perform a query on a query result, but I am getting an error: “The method or operation is not implemented”. Can I chain queries in this way? For example, I have a Northwind typed DataSet. I do: queryResult = From product In NorthWindDataSet.Products Where (product.UnitsOnOrder > CInt(txtUnitsOnOrde...

How to add empty or custom value to a bound combobox?

I am using a System.Windows.Forms.Combobox bound to Category table as search criteria. I need to have a value “All” or empty string that will be selected when user does not want to use this criteria. Since combo is bound, each time it is clicked, value added by combo1.Text = “All” is erased. Obviously, I can’t add “All” category to data...

Is it possible to conditionally compile to .NET Framework version?

I can recall back when working with MFC you could support multiple versions of the MFC framework by checking the _MFC_VER macro. I'm doing some stuff now with .NET 4 and would like to use Tuple in a couple of spots but still keep everything else 3.5 compatible. I'm looking to do something like: #if DOTNET4 public Tuple<TSource, T...

Unloading an appdomain with references

I'm new to using appdomains, so I'm learning as I go. I'm making use of appdomains to isolate plugin instances that I'm loading at runtime. If I am referencing a plugin object (in its own appdomain) from the main appdomain and I unload that plugin appdomain, will it fully unload? My understanding is that by referencing the plugin inst...

How can I apply a GradientBrush to multiple consecutive objects in XAML?

I have a TextBlock and a Line sitting next to each other in their own exclusive StackPanel. I need to spread my LinearGradientBrush across the two objects, rather than shading them individually. My project currently looks like this: <StackPanel Orientation="Horizontal"> <TextBlock VerticalAlignment="Bottom"> SomeT...