.net

Open a .NET WPF window or Windows Form from VBA code.

Hi, Can anyone give me the syntax required to call a .NET assembly from VBA code. I want to open a WPF window or Windows form from an Access form. Malcolm ...

Set App TimeZone using PInvoke .Net

I have used PInvoke to change the TimeZone of my Clients System. Instead of that Iwould like to change TimeZone of my Application only. Is there a workaround for this. ...

How to clear System.Windows.Forms.WebBrowser session data?

How can I clear current session data (cookies, cached data, auth sessions, etc) without restarting the application? Update: I'm talking about WebBrowser control in Windows.Forms, not the ASP.Net session. ...

Serial Port (rs232) in Mono for multiple platforms

I am planning on re-writing a Win32 application (native C++) in .NET - most likely using mono so I can run it on Win32, Linux and mac. The problem I am trying to solve (having only really developed for Win32) is an issue with the serial port definition. How does one typically identify differences in platform when there is only supposed...

Read Csv file encoding error

I am using the following method for reading Csv file content: /// <summary> /// Reads data from a CSV file to a datatable /// </summary> /// <param name="filePath">Path to the CSV file</param> /// <returns>Datatable filled with data read from the CSV file</returns> public DataTable ReadCsv(string filePath) { ...

Array versus List<T>: When to use which?

MyClass[] array; List<MyClass> list; What are the scenarios when one is preferable over the other? And why? ...

Silverlight: How to ignore (the absence of) crossdomain.xml with System.Net.WebClient?

I get security exception when using System.Net.WebClient to do HTTP requests, which is due to the fact that crossdomain.xml or clientaccesspolicy.xml on the target server are either missing or are too restrictive. I know there is a good reason for this (cookies and cross-site request forgery), but it does not apply in my case since all I...

How to design this method if it returns multi-dimensional arrays?

I am now designing an SNMP library. The problem is caused by a special function like this, *** GetTable(string id) This function may return Variable[,] which is a two dimensional array sometimes, but also Variable[,,] and arrays with more dimensions. So I believe it is not reasonable to return fixed array such as Variable[,], Variable[...

How to determine installed IIS version

What would the preferred way of programmatically determining which the currently installed version of Microsoft Internet Information Services (IIS) is? I know that it can be found by looking at the MajorVersion key in HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W3SVC\Parameters. Would this be the recommended way of doing it, ...

Dont let excel open the file if it is already opened

I'm using Microsoft.Office.Interop.Excel.Workbooks.Open Method http://msdn.microsoft.com/zh-tw/library/microsoft.office.interop.excel.workbooks.open(VS.80).aspx This method opens a dialog window if the file is already opened, asking the user if he wants to open as read-only or not open (the method returns null if user chose to not open...

.Net Function call in SQL 2005

I am getting the following error when I execute a .Net Function in SQL 2005, any ideas? Msg 6522, Level 16, State 2, Line 1 A .NET Framework error occurred during execution of user defined routine or aggregate 'Function1': System.Security.SecurityException: Request for the permission of type 'System.Net.WebPermission, Sy...

How do I use the IComparable interface?

I need a basic example of how to use the IComparable interface so that I can sort in ascending or descending order and by different fields of the object type I'm sorting. ...

What is the preferred way to find focused control in WinForms app?

What is the preferred/easiest way to find the control that is currently receiving user (keyboard) input in WinForms? So far I have come up with the following: public static Control FindFocusedControl(Control control) { var container = control as ContainerControl; return (null != container ? FindFocusedControl(container....

How to use the same C# 2008 project for both x86 and CF.Net targets?

Hi, I have a C# project in VS2008 which I wish to build for two targets - x86 and the compact framework for dot net (CF.Net) depending on a chosen configuration (say Debug/SmartDeviceDebug etc). How do I go about this? I have an inkling this can be done somehow using the command line and msbuild but I am interested in a solution which w...

Code for a simple thread pool in C#

Looking for some sample code (C#) for a simple thread pool implementation. I found one on codeproject, but the codebase was just huge and I don't need all that functionality. This is more for educational purposes anyways. ...

How to add data to a new formed column

I am trying to add data to a newly created column... DataSet ds = new DataSet; ds.Tables[0].Columns.Add("Count"); Data.DataSource = ds; Data.DataBind(); Where do I add, a hardcoded count? (I want count column to have '4') ...

ASP.Net Forms Authentication Logging out users after 10 minutes.

I am having a really bad issue where no matter what I try, the user is being logged off after 10 minutes. I am using ASP.Net 2.0 running on IIS 6.0 on Server 2003 R2 Standard Edition running as a Virtual Server with all applicable updates and .Net 3.5 SP1. The client is Internet Explorer 7.0 Below are the web.config settings: <!-- Au...

Can anybody recommend a PDF solution for the Compact Framework?

We have a requirement to generate PDF documents using information from a PDA / Mobile Phone. We cannot send the information back to a server as the information is required immediately and the engineers with the devices may be out of coverage. So, can anybody recommend a .NET compact framework component for producing PDFs? Could you als...

Compact Framework - Retrieve a list of countries and regions

Afternoon people! I'm trying to implement a list of counties on my Compact Framework (Mobile) application. I can do this easily in the full .Net framework with CultureInfo.GetCultures(..etc). However, the CF seems to be missing this feature? Is there any way I can return a list of countries (and regions if possible) that I can populat...

How to improve data access layer select method Pattern

Lately I find myself writing data access layer select methods where the code all takes this general form: public static DataTable GetSomeData( ... arguments) { string sql = " ... sql string here: often it's just a stored procedure name ... "; DataTable result = new DataTable(); // GetOpenConnection() is a private method i...