.net

How do I generate an RSA public/private key in .Net, of a specific length?

I'm using the RSACryptoServiceProvider to do some asymmetric encryption. As per MSDN, when you instantiate a new RSACryptoServiceProvider, you get a public/private key pair generated for you that you can use. Clearly this pair is being generated using some defaults - specifically the length. I'd like to specify my own length for great...

SqlDataReader.GetString and sqlnullvalueexception

I am new to C#. I was executing some select queries from database tables using System.Data.SqlClient classes. I got sqlnullvalueexception while executing some select query. On googling I come to know that if the value is null in the database, SqlDataReader.GetString (or it's variants) will throw sqlnullvalueexception. What is the best co...

Exit Installation from custom action(public method in a managed assembly) return type

Install Shield 2009 Premier, Basic MSI Project. Custom Action properties are: Type: Call a public method in a managed assembly Location: Stored in the binary table Specified the class and method name, it shows a message box (so that i'm sure its called) and returns 13 integer value. [didn't choose any Return Property, don't know what...

Do I need to lock or mark as volatile when accessing a simple boolean flag in C#?

Lets just say you have a simple operation that runs on a background thread. You want to provide a way to cancel this operation so you create a boolean flag that you set to true from the click event handler of a cancel button. private bool _cancelled; private void CancelButton_Click(Object sender ClickEventArgs e) { _cancelled = tru...

What is the best way to get the executing exe's path in .NET?

Hi, From program a.exe located in c:/dir I need to open text file c:/dir/text.txt. I don't know where a.exe could be located, but text.txt will always be in the same path. How to get the name of the currently executing assembly from within to program itself so that i can access the text file? EDIT: what if a.exe is a Windows service? I...

How can I serialize a DevExpress XtraReport report design

Hello everybody, I need to serialize a report design. This is the scenario: The app has base reports, let's say "Sales Report" with a set of pre-defined columns and design, like the corp. logo in the header. The users needs to have the ability to change that layout adding, for example, a footer with the office address, or page numbers...

How do I find out what volume a given NTFS path is on when using mount points?

I have an Exchange server with lots of mountpoints. Given the path to the database files is there a way to find out what volume they are on? The problem is that they are typically not at the volume mount point, but further down the tree. I'm using Powershell, so I need a solution preferably using WMI but could also use any .NET or COM...

Displaying an Image in a WebBrowser Control without accessing external Files

I am using the WebBrowser Control in C# in an application to display HTML. All the data comes from a database, so I am generating a full page with Inline-CSS in Memory and sending it to the browser. But now I want to support images, which seems to be a problem because I do not want to store the images on Hard drive, not even in a Temp D...

Dynamically overriding a method -or- observing when a method is called at runtime?

I'm primarily an Objective-C/Cocoa developer, but I'm trying to implement the Observer pattern in C#.NET, specifically mimicking the NSKeyValueObserving protocols and methodology. I've gotten as far as mimicking NSKVO with manual support, as described in Apple's KVO Programming Guide (see http://tinyurl.com/nugolr). Since I'm writing th...

Exception setting up handler for AppDomain.AssemblyResolve

Create a new appdomain, setup the assemblyResolve handler and you always get an exception saying 'assembly [current executing assembly] not found' what gives ? code is below string _fileName = @"c:\temp\abc123.dll"; AppDomain sandBox = AppDomain.CreateDomain("sandbox"); sandBox.AssemblyResolve += new ResolveEventHandler(sandBox_Ass...

How can I create a finger scrollable Textbox in WM 6.5?

Hi everybody. I just noticed something weird in WM 6.5 emulators. Unlike 6.1 where finger panning kind of worked, the only way to scroll a Textbox appears to be through scrollbars. This behaviour is in contrast to what they have done for comboboxes: they are now gesture-friendly without the programmer's intervention. I.e. the user can ...

Can textbox input in C# be restriced to a formatted type?

I'd just like to know if there's a function/way to restrict input to a textbot to a formatted type e.g. a user can only enter a date type into a textbox; or a function similar to to the C scanset that I can use to achieve the same functionality? Thanks ...

DeSerialization doesn't work though i Implement GetObjectData method and Constructor

Hi, I have a static generic dictionary in a class. As static memeber cannot serialized so i have implented ISerializable interface and method GetObjectData to serialize. I have a constructor which will also accept SerializationInfo and StreamingContext to deserliaze the dictionay. Now when i try to serialize and deserialize , it always...

Trouble using/displaying special characters from Oracle db in .Net app

I have a C#.Net application that accesses data from a commercial application backed by an Oracle 10 db. A couple of fields in the commercial app's database (declared as varchar2(n)) contain special characters. The "smart quote" apostrophe, for example. The commercial client app displays these characters correctly, but my application i...

How to release late bound COM objects?

I guess I do have to release also late bound COM objects. But how is this done directly? In my situation I use the following code from C# to get the focused point from Google Earth (simplified): Type oClassType = Type.GetTypeFromProgID("GoogleEarth.ApplicationGE"); object oGE = Activator.CreateInstance(oClassType); object oCamera = oGE...

How do I show a custom palette in the Designer?

Our graphic designer would like us to use his colour palette for our winforms application. Is it possible to display this palette in the designer, similarly to the system palette, rather than having to enter the colours by hand every time? ...

validate 3 textfields representing date of birth

I have 3 text box fields. to represent a date eg DD MM YYYY how can i validate only correct data is entered into each text box. is it a regexpression?? i need to do this inside the ascx/aspx file rather than the .cs codebehind thanks ...

How to make scrollbars appear in a resizable panel when the contained control is too big for it ?

I am developing a Windows Forms application (.NET 2.0, VS 2005). I have a form that essentially contains a panel that is dynamically resized with the form : this.panel1.Dock=DockStyle.Fill; This panel is simply used as a container. At runtime, a custom control will be added : UserControl uc=new UserControl(); panel1.Controls.Add(uc);...

Subsonic 3.0 and DB2 support?

It doesn't appear so from the online docs, but I wanted to ask the question here anyway......Will Subsonic 3.0 support DB2? Specifically......I'm working on an enterprise app that needs to connect to DB2 on MVS. ...

Why don't structs support inheritance?

I know that structs in .NET do not support inheritance, but its not exactly clear why they are limited in this way. What technical reason prevents structs from inheriting from other structs? ...