Friday, 16 November 2007
|
| Casting null to nullable Brady Kelly 11:12:22 |
| | I find this requirement quite unintuitive and clumsy. Is there anything to be said in its defence? I thought nullable types were supposed to save us this kind of friction.
=================================== This list is hosted by DevelopMentor http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com
|
| | 4 answer | Add comment |
|
| C# / CLR Course Syllabus Brady Kelly 04:19:01 |
| | I will be giving a colleague training in C#, and would like to offer it in the form of a series of one day courses. I would like to cover beginners and intermediate level practical, real world, programming in, say, four courses, and I would like some input on my syllabus. So far I see language basics, and common tasks, e.g. basic data access, in course #1; collections and .NET classes, and Windows Forms essentials in course #2; component design and implementation, interfaces, inheritance, generics, reflection etc. in course #3; and course #4 as a guided practical project, of nature still to be determined.
=================================== This list is hosted by DevelopMentor http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com
|
| | 6 answers | Add comment |
Thursday, 15 November 2007
|
| ExceptionManager and publishing custom exceptions Darryl Luther 21:19:00 |
| | I'm trying to configure exception management in a web app to email different addresses depending on the exception generated. To this end I've created my own exception class that implements ApplicationException. For these custom exceptions I'd like the email to go to a different address than all the other exceptions so I have two publisher nodes in web.config as follows:
<exceptionManagement> <publisher mode="on" assembly="IntranetMaintenance" type="IntranetMaintenance.ExceptionMailPublisher" exclude="IntranetMaintenance.DuplicateFileException" mailserver="mail.exceptions.com" mailfromaddress="noreply@exceptions.com" mailfromname="Intranet Maintenance Exception" mailto="general.exceptions@exceptions.com" mailsubject="Unhandled Intranet Maintenance Exception"> </publisher> <publisher mode="on" assembly="IntranetMaintenance" type="IntranetMaintenance.ExceptionMailPublisher" exclude="*" include="IntranetMaintenance.DuplicateFileException" mailserver="mail.exceptions.com" mailfromaddress="noreply@exceptions.com" mailfromname="Intranet Maintenance Warning" mailto="warning.exceptions@exceptions.com" mailsubject="Intranet Maintenance Duplicate File Warning"> </publisher> </exceptionManagement>
"IntranetMaintenance" is the namespace for the web app and "DuplicateFileException" is my exception class implementing ApplicationException. Here's how I create the exception in code:
DuplicateFileException e = new DuplicateFileException("Duplicate file found"); NameValueCollection additionalInfo = new NameValueCollection(); additionalInfo.Add("User", _user); additionalInfo.Add("Workarea", _workarea); additionalInfo.Add("File", f.Name); additionalInfo.Add("Exception Type", e.GetType().ToString()); ExceptionManager.Publish(e, additionalInfo);
I added the Exception Type just to make sure that I was indeed specifying the right type to exclude/include in my publisher nodes. The problem is that this exception is still emailed to "general.exceptions@exceptions.com". Clearly I am doing something wrong, but I cannot see what it is. I think I have everything configured properly for what I'm trying to do. Does anyone have any ideas or suggestions? Thanks!
Darryl Luther
=================================== This list is hosted by DevelopMentor® http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com
|
| | Add comment |
|
| Re: Design Time Data Brady Kelly 05:56:50 |
| | Hi Rich
I can't make out very much of your post, but regarding parameters for stored procs: What I do is create a new dataset, then drag a stored proc from Server Explorer onto it. That creates a DataTable and a TableAdapter, and a default Fill method using the stored proc I dragged. I then right click the TableAdapter in the dataset designer, and select additional, existing, stored procs for update, insert, and delete. If the parameter names for the latter three match the column names selected in the first proc, VS auto-magically handles passing these parameters.
-----Original Message----- From: Discussion forum for developers using Windows Forms to build apps and controls [mailto  OTNET-WINFORMS@DISCUSS.DEVELOP.COM] On Behalf Of R. Rogers Sent: 14 November 2007 06:23 PM To: DOTNET-WINFORMS@DISCUSS.DEVELOP.COM Subject: [DOTNET-WINFORMS] Design Time Data Hello, So far in my relatively simple winforms app, I $B!G (Bve been doing all database work in code. I do all the following in code: - Instantiate a SqlConnection and connect - Instantiate a SqlCommand and a whole bunch of SqlParameter objects to call a stored procedure This is working well, but is time consuming. I like the fact that I have a lot of control this way and can use the SQL Server optimized classes. The only downside is it $B!G (Bs time consuming and code maintenance might become a burden. I would like it if VS would at least be able to setup the parameters for the stored proc. To move in that direction, I started a new project, and clicked on $B!F (BData $B!G (B $B"* (B $B!F (BAdd new Data Source $B!G (B. I $B!G (Bve now got an associated $B!H (Bdata module $B!I (B (Delphi speak). I thought I $B!G (Bd be able to create connections and commands at design time, but this isn $B!G (Bt so. The only components I see under the data section are: - Dataset - DataGridView - BindingSource - BindingNavigator I expected to see SqlConnection, SqlCommand, etc. Could someone enlighten me, with perhaps a weblink or two? Much appreciated! Richard Rogers (MSN) rogersrr_ca@hotmail.com
|
| | 2 answer | Add comment |
|
| UserControl in DataGridView cell Francisco Serrano 05:22:40 |
| | Hi!:
I have created a user control with one textbox and a button, and I need this control to be loaded in the datagridview. In a cell the value is the text property of the textbox. I have seen some examples but with the keyboard and the focus have problem. (There are answers in others threads by Mark Rideout and Zhi-Xin Ye, but not a complete example running with the keyboard).
Any complete code example?
Thanks in advance
|
| | 10 answers | Add comment |
Wednesday, 14 November 2007
|
| Resending R. Rogers 19:43:01 |
| | Strange with the formatting, hopefully this shows up better now:
So far in my relatively simple winforms app, I've been doing all database work in code. I do all the following in code: - Instantiate a SqlConnection and connect - Instantiate a SqlCommand and a whole bunch of SqlParameter objects to call a stored procedure
This is working well, but is time consuming. I like the fact that I have a lot of control this way and can use the SQL Server optimized classes. The only downside is it's time consuming and code maintenance might become a burden.
I would like it if VS would at least be able to setup the parameters for the stored proc. To move in that direction, I started a new project, and clicked on 'Data' ? 'Add new Data Source'.
I've now got an associated "data module" (Delphi speak). I thought I'd be able to create connections and commands at design time, but this isn't so. The only components I see under the data section are: - Dataset - DataGridView - BindingSource - BindingNavigator
I expected to see SqlConnection, SqlCommand, etc. Could someone enlighten me, with perhaps a weblink or two?
Much appreciated!
Richard Rogers http://www.RichardRogers.ca/ (MSN) rogersrr_ca@hotmail.com
Richard Rogers http://www.RichardRogers.ca/ (Home) 416-787-4777 (Cell) 416-723-7427 (MSN) rogersrr_ca@hotmail.com
|
| | Add comment |
|
| C# 3.0 Automatic Properties IMPlatform 14:02:19 |
| | As I don't have a trial version of the VS2008 - I understand the syntax is
Public string Name { get, set };
Can I change the access modifiers of the get and set something like
Public string Name { get, internal set };
Rob.
=================================== This list is hosted by DevelopMentor http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com
|
| | 30 answers | Add comment |
Tuesday, 13 November 2007
|
| Sorted Dictionary / List woes. Amit Bhatnagar 19:22:17 |
| | Hi All.
I have a problem that I think a System.Collections.Generic.SortedList/Dictionary can solve, but I am unable to get it to work.
I want to store a list of messages in a collection where I can check if an entry already exists quickly (dictionary), but also be able to return these messages in chronological order - so I thought a SortedDictionary is what I wanted to do here.
So I create it like SortedDictionary<long, MessageInfo> where MessageInfo is a class that contains all the required info of a message, and the long key is a unique identifier so I know if I am adding duplicates.
Now what I wanted to do is create a IComparer<> on the DateTime within the MessageInfo so that the SortedDictionary would use that to sort, but it seems that the IComparer I make has to work on the type of the key (in this case, long), or it won't complile. I guess it is only ment to sort the keys of the key/value pair.
Does anyone know what else I could do so I can have a collection that is keyed on a unique ID, but also have the ability to return these values in chronological order?
thanks.
The information contained in this e-mail message is PRIVATE. It may contain confidential information and may be legally privileged. It is intended for the exclusive use of the addressee(s). If you are not the intended recipient, you are hereby notified that any dissemination, distribution or reproduction of this communication is strictly prohibited. If the intended recipient(s) cannot be reached or if a transmission problem has occurred, please notify the sender immediately by return e-mail and destroy all copies of this message. Thank you.
|
| | 6 answers | Add comment |
Monday, 12 November 2007
|
| Warning: Unreachable code detected R. Rogers 22:40:50 |
| | Hi,
I like coding defensively, and correct me if I'm wrong, but I think the following code demonstrates this to a very small degree:
switch (code) { case 1: result = DialogResult.OK; break;
case 2: result = DialogResult.Cancel; break;
case 3: throw new ApplicationException("No such logon session."); break;
... }
The trouble is that if I break after throwing an exception, the compiler gives me an "unreachable code detected" message, and I don't like any warnings.
Would you have any advice to share on this? I don't really want to get rid of the break statement.
Best regards,
Richard Rogers http://www.RichardRogers.ca/
|
| | 5 answers | Add comment |
|
| RichTextBox BackColor of Selected RTF Richard Kucia 20:18:32 |
| | I need to grab some RichText from a RichTextBox and paste it at an insertion point into a second RichTextBox. After the paste, the new text is supposed to be black text on a yellow background.
There is no SelectionBackColor property on the RTB, so that's out.
I've tried to paste the RTF into a temporary RTB and set that RTB's ForeColor and BackColor properties. That works -- on the temporay RTB. When I grab that RTF and paste it into the final RTB, it acquires the colors of the surrounding text.
I can select the inserted RTF and adjust its ForeColor, but there's no method to set its BackColor.
A Google search has turned up a lot of suggestions that involve either a) parsing the raw RTF, or b) SendMessage calls, or c) third-party substitutions for the Microsoft RTB. All of these options are out-of- bounds for my application.
Is there an alternative?
Thanks.
Rick Kucia
|
| | Add comment |
Thursday, 8 November 2007
|
| CredUIPromptForCredentialsW R. Rogers 11:24:36 |
| | Hi everyone,
I'm using a C# class that acts as a thin wrapper around the CredUIPromptForCredentialsW function.
A good article on this function is written here: http://msdn2.microsoft.com/en-us/library/aa480470.aspx
When calling the function with the INCORRECT_PASSWORD flag, the balloon hint doesn't appear. I found out that this is because this flag was introduced after XP, and only works on Win 2003 or later. I am developing and deploying on XP.
I wonder how I can use the function differently to indicate that a login failed.
Any ideas are very welcome!
Richard Rogers http://www.RichardRogers.ca/
|
| | 1 answer | Add comment |
Wednesday, 7 November 2007
|
| Remoting and Threads Strele Franz 18:06:50 |
| | I'm learning about .NET remoting and have created an application with a client- and a server-part. The client uses an object from server via remoting and an IpcChannel. Now when the client calls methods on that object, those are executed on a different thread than the thread that created this object on the server. Is it possible to have them execute on the same thread?
Any information is much appreciated.
Thanks, Franz
Code used at the server-side:
IpcServerChannel channel = new IpcServerChannel("RemotingTest"); ChannelServices.RegisterChannel(channel, false); RemotingConfiguration.RegisterWellKnownServiceType(typeof(MyRemoteObject ), "MyRemoteObject", WellKnownObjectMode.Singleton);
MyRemoteObject testObject = new MyRemoteObject();
RemotingServices.Marshal(testObject, "MyRemoteObject");
Code used at the client-side:
IpcClientChannel channel = new IpcClientChannel(); ChannelServices.RegisterChannel(channel, false);
MyRemoteObject testObject = (MyRemoteObject)Activator.GetObject(typeof(RemoteApplication), "ipc://RemotingTest/MyRemoteObject");
testObject.SomeMethod();
=================================== This list is hosted by DevelopMentor http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com
|
| | 7 answers | Add comment |
|
| Expand and collapse detail editing Brady Kelly 13:06:22 |
| | I have a Repeater control that hosts simple User List rows of system users. Each row has an Edit icon, which the user clicks to open a User Details edit page. I have been told to remove the separate details page, and create a detail edit section that expands or collapses on demand, without leaving the base User List page. How do I go about this?
My first idea is to include an edit control on the item template of the Repeater, and simply use styling to hide the edit control until the edit icon is clicked. Then I set the display to a visible, and the edit control handles all the edit functionality itself. Is this the correct approach, how could I improve on this, and what pitfalls await me?
=================================== This list is hosted by DevelopMentor http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com
|
| | 3 answer | Add comment |
Monday, 5 November 2007
|
| Grid from TexBoxes is Slow Brady Kelly 16:12:52 |
| | I've build a prototype custom grid using rows of TextBox controls, but it's quite slow. Now if I use a DataGridView, with all my columns as textbox columns, I imagine all the cells are textboxes as well, and that grid has huge amounts more functionality than mine. So, I believe I can greatly improve the speed of my grid, still using the textbox approach, but I haven't a clue how. Some advice would be great.
A question that keeps cropping up in my thoughts is, do I continue delegating the drawing of borders to the individual textboxes, or do I draw the grid independently, and place borderless textboxes in the cells. Is there even much of a difference?
|
| | 8 answers | Add comment |
|
| Reflection problems Dean Cleaver 10:57:35 |
| | I've got some code that worked before, doesn't work now. Pretty simple code really - the core of the problem is that Reflection has now decided that my classes don't implement an interface that I can guarantee they do implement, and it will not cast the returned object to that interface.
I'm going out of my tree here - I have recompiled everything, checked everything, and it still just does a big nothing - anyone know what can cause this to occur?
Dino
=================================== This list is hosted by DevelopMentor http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com
|
| | 16 answers | Add comment |
Sunday, 4 November 2007
|
| Complex (for me anyway) Marshalling Simon Hewitt 17:53:03 |
| | I've been working on an LDAP library and I've managed to work out how to read info from Active Directory. I'm now trying to write information back (or delete) and I can't work out the signatures/struct to use or whether I need to allocate unmanaged memory and pass that instead.
The LDAP API stuff and my managed definitions are:-
WINLDAPAPI ULONG LDAPAPI ldap_modifyW( LDAP *ld, PWCHAR dn, LDAPModW *mods [] );
[DllImport("wldap32.dll", CharSet=CharSet.Auto)] public static extern int ldap_modify_s(HandleRef pLDAPSession, /* PCHAR */ [In] string dn, /* LDAPMod* */ [In, Out] LDAP.LDAPMod[] mods);
(I'm pretty sure that the first two parameters and the return value are correct since I've used their values in other LDAP functions successfully)
and
typedef struct ldapmodW { ULONG mod_op; PWCHAR mod_type; union { PWCHAR *modv_strvals; struct berval **modv_bvals; } mod_vals; } LDAPModW, *PLDAPModW;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] public class LDAPMod { public int ModOp; [MarshalAs(UnmanagedType.LPStr)] public string ModType; public object[] Values;
}
(Values will be set to a String[] for the purposes of this test - I'll work on the binary stuff later)
The code I am using to delete an existing attribute is:-
LDAP.LDAPMod[] modifications = new LDAP.LDAPMod[modificationList.Count + 1]; modificationList.CopyTo(modifications); modifications[modificationList.Count] = null; int result = LDAP.API.ldap_modify_s(_session._LDAPSession, DN, modifications);
modifications[0] is {0x02, "description", null} (0x02 is LDAP_MOD_REPLACE and the null should delete all existing values) modifications[1] is null (required to serve as the list terminator
I get error 0x59 which is LDAP_PARAM_ERROR
I will be grateful for any help or pointers.
Cheers Simon
You can read messages from the Advanced DOTNET archive, unsubscribe from Advanced DOTNET, or subscribe to other DevelopMentor lists at http://discuss.develop.com.
|
| | 6 answers | Add comment |
Saturday, 3 November 2007
|
| Applications of PowerShell Brady Kelly 18:30:22 |
| | Does anyone on this list use it, and for what? I'm looking for practical examples for a talk I'll be giving.
=================================== This list is hosted by DevelopMentor http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com
|
| | 5 answers | Add comment |
|
| Custom Grid: Multiple data tables Brady Kelly 18:25:11 |
| | I'm busy designing a custom grid that should be able to accommodate interleaved rows with varying column structures. I only need very lightweight functionality, so instead of extending a DataGridView, I'm creating my grid from scratch using a DataRowControl, which is a Panel with one Textbox for each column in the definition for a row. Then I arrange a collection of these DataRowControls vertically, one for each row in my data source, on another panel. Is there a better way to do this?
Now, when I do what I describe above, the first problem I find, and I'm sure you'll see many more posts on this here by me, is sizing. I don't want a scrollbar on each row, so my row Panel has AutoScroll set to false, but the Panel holding all the rows has AutoScroll = true. However, in this arrangement, I still only get vertical scrolling. Am I doing something wrong?
In summary, is my whole approach to this problem on the right track? It seems to be working well enough for a start, but I'd like to know if I'm going to get into any trouble that others may have found on this path.
|
| | Add comment |
|
| Weird generic types Dave 12:19:10 |
| | Hey community,
I've got a cool one here
I'm facing a real (business) problem. Well, it's more about a Thursday night trying to figure out ways to do things, but here it is:
And yah, it's written in VB, didn't feel like C#ing. But! I don't think the problem is high-level. So whatever the language. C#ers around here will be able to read it like normal code.
Module Module1
Sub Main()
Dim more As MoreSpecific
Dim less As IBase(Of IItem)
more = New MoreSpecific()
Try
less = CType(more, IBase(Of IItem))
less.Add(New MyItem("dave"))
Console.WriteLine("success")
Catch ex As Exception
Console.WriteLine(ex.ToString())
End Try
Console.ReadLine()
End Sub
End Module
Public Interface IItem
ReadOnly Property Name() As String
End Interface
Public Interface IBase(Of T)
Sub Add(ByVal item As T)
End Interface
Public Interface ILessSpecific
Inherits IBase(Of IItem)
End Interface
Public Interface IMoreSpecific(Of T As IItem)
Inherits IBase(Of T)
End Interface
Public Class MyItem
Implements IItem
Private _name As String
Public Sub New(ByVal name As String)
_name = name
End Sub
Public ReadOnly Property Name() As String Implements IItem.Name
Get
Return _name
End Get
End Property
End Class
Public Class MoreSpecific
Implements IMoreSpecific(Of MyItem)
Public Sub Add(ByVal item As MyItem) Implements IBase(Of MyItem).Add
'add to collection, or something..
End Sub
End Class
Everything compiles fine.
Here's the runtime error message:
System.InvalidCastException: Unable to cast object of type 'ConsoleApplication53.MoreSpecific' to type 'ConsoleApplication53.IBase`1[ConsoleApplication53.IItem]'.
at ConsoleApplication53.Module1.Main() in F:\Data\Dave's documents\Visual Studio 2005\Projects\ConsoleApplication53\Module1.vb:line 10
Someone here understand why the cast is invalid?????????
I can't.
Sweet dreams.
Peace.
And check http://omniscienttrader.com <http://omniscienttrader.com/>
Coming slowly but surely.
David Lacerte
Chief Knowledge Officer
Omniscient Technology Inc
=================================== This list is hosted by DevelopMentor http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com
|
| | 4 answer | Add comment |
Thursday, 1 November 2007
|
| Iterating through DataGridView.Rows R. Rogers 23:48:39 |
| | Hi,
dgFilesToProcess is a DataGridView. dgFilesToProcess.SelectionMode = FullRowSelect. dgFilesToProcess.ShowEditingIcon = true.
Here's my code: DataGridViewCheckBoxCell ProcessedCell; DataGridViewTextBoxCell UploadTypeCell; DataGridViewTextBoxCell FilenameCell;
foreach (DataGridViewRow FileToProcess in dgFilesToProcess.Rows) { ProcessedCell = (DataGridViewCheckBoxCell)FileToProcess.Cells["Processed"]; UploadTypeCell = (DataGridViewTextBoxCell)FileToProcess.Cells["UploadType"]; FilenameCell = (DataGridViewTextBoxCell)FileToProcess.Cells["Filename"];
// MessageBox.Show(FilenameCell.Value.ToString()); ProcessedCell.Value = true; }
Simple question (hopefully): As I iterate, how can I advance the "current row indicator" on the screen?
Thanks,
Richard Rogers http://www.RichardRogers.ca/
=================================== This list is hosted by DevelopMentor http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com
|
| | Add comment |
|
| Programatically generating Word 2007 documents Paul ten Brink 10:48:33 |
| | Hello,
I want to programmatically generate Open XML Word 2007 documents on the server without using automation and going through the object model of Word itself.
Unfortunately googling returns only limited/fragmented information on this topic.
Any references, links, books, third party components that you know of?
Thanks a lot in advance, Paul ten Brink paul.ten.brink@philips.com
=================================== This list is hosted by DevelopMentor http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com
|
| | 6 answers | Add comment |
Wednesday, 31 October 2007
|
| Storing configuration in user.config Alex Ivanoff 21:07:20 |
| | Up to this point I was mostly working on server .NET applications and storing all configuration in Appname.exe.config file worked just fine. Now I am working on a client GUI application and working with configuration is different. So I am storing global readonly configuration in Appname.exe.config (like data file location, GC settings, etc.) and read/write configuration in user level config files.
And here go my problems. I can set some user level settings through usage of .settings file. But how do I configure tracing? How do I manage user.config files in VS IDE projects and not through .settings files?
|
| | 2 answer | Add comment |
Tuesday, 30 October 2007
|
| Dynamically Update ListBox Item Brady Kelly 19:55:46 |
| | I have as a ListBox item a reference to a ScrollingLine class, in which I override ToString() to return the part of text currently visible in a scrolling window. How do I get my ListBox to update its display of that string? Does it make a copy of the ToString() result of each item when initialising, or does it just not know to update and maybe I could invalidate it?
|
| | Add comment |
|
| Edit and Continue in ASP.NET Brady Kelly 19:16:04 |
| | Is there any way to achieve this at all?
=================================== This list is hosted by DevelopMentor http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com
|
| | Add comment |
|
| Standard Database Connection Dialog R. Rogers 19:06:08 |
| | Hi again,
I'm looking for a standard DB Login screen, that would prompt for username and password, and allow Ok or Cancel to be clicked. It would be similar to the class System.Windows.Forms.OpenFileDialog.
I see this: http://msdn2.microsoft.com/en-us/library/6bhahz63(VS.71).aspx but where's the beef?
Richard Rogers http://www.RichardRogers.ca/
|
| | 5 answers | Add comment |
|