Windows Develop Bookmark and Share   
 index > Windows Forms Designer > Overriding TextBox.WndProc problems
 

Overriding TextBox.WndProc problems

I've written a custom textbox which only allows numerical input.  I overrid the WndProc method so i could validate the clipboard contents if the user pasted data into the textbox as shown below:

protected override void WndProc(ref Message m) 
{
    switch (m.Msg)
    {
        case 0x0302:
            if (Clipboard.GetDataObject().GetDataPresent(DataFormats.Text))
            {
                string paste = Clipboard.GetDataObject().GetData(DataFormats.Text).ToString();
                string text = this.Text.Substring(0, this.SelectionStart) + paste + this.Text.Substring(this.SelectionStart + this.SelectionLength);

                if (this.IsValid(text))
                {
                    base.WndProc(ref m);
                }
            }
            break;
        default:
            base.WndProc(ref m);
            break;
    }
}

The control works fine, the problem is that if i package this up into a dll and the move it to our server for the other developers to use they get an error when they try to add the control to their tool bar. When i tried it i got the same problem, however, if i add a local copy of the dll it works.

The error is something about not being able to open it and to check for missing referenced files, however, the dll only references inbuilt .net dlls.

If i remove the overloaded WndProc method, it works fine, im convinced its a .net security problem, but its just a guess.

Any ideas?
MigrationUser 1  Tuesday, December 09, 2003 9:35 AM
Are the other devs trying to add this assembly from a network share? By default .net security gives much lower permissions to assemblies loaded from network shares.
MigrationUser 1  Friday, December 12, 2003 7:41 AM
yes they are, is there any way to fix this?
MigrationUser 1  Monday, December 15, 2003 3:16 AM
You can strongly name the assembly you are using and then give the assembly escalated permissions.  In general you would simply need the devs to run a batch file that sets up the strong name with full privs and then they could load the assembly from the share.
MigrationUser 1  Monday, December 15, 2003 3:02 PM

You can use google to search for other answers

Custom Search

More Threads

• Windows Forms designer is missing
• AutoValidation problem with windows forms
• Problem with refreshing parameter collection in designer mode
• AutoToolboxPopulate option question
• date validation
• Customising a Data Grid hierchal layout to a flat umnormalised structure
• what the heck? Clicked on the background image property of a form, and everything went haywire!
• How to reorder/swap tabpage in runtime
• Custom UITypeEditor not working for properties of type "System.Windows.Forms.Control"
• ActiveX design does not save