Custom Filter for PropertyGrid

S

Steven

I'm trying to set a custom filter for propertygird's FileNameEditor.

//property
[DisplayName("File Path")]
[Category("Video Settings")]
[Description("The path to the file to be played.")]
[System.ComponentModel.Editor(typeof(MovieFileNameEditor),
typeof(UITypeEditor))]
public string FilePath
{
get { return _FilePath; }
set { _FilePath = value; }
}


//FileNameEditor override
internal class MovieFileNameEditor :
System.Windows.Forms.Design.FileNameEditor
{
protected override void InitializeDialog(OpenFileDialog openFileDialog)
{
base.InitializeDialog(openFileDialog);

openFileDialog.Filter = "Movie Files (*.avi, *.mpeg,
*.mpg)|*.avi;*.mpeg;*.mpg";
openFileDialog.Title = "Select Movie File";
}
}

If I try to override either UITypeEditor or FileNameEditor I get an
unhandled exception:

System.BadImageFormatException: Could not load file or assembly 'MyDLLName,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its
dependencies. The module was expected to contain an assembly manifest.

But if I use the .NET versions it works fine:
[System.ComponentModel.Editor(typeof(System.Windows.Forms.Design.FileNameEditor),
typeof(System.Drawing.Design.UITypeEditor))]

But of course I don't get my filtering.

What's causing the BadImageFormatException when I use my own class?

VS2008/.NET version 3.5/C#
Project: Class Library

Thanks in advance,

Steven
 
S

Steven

One more odd thing, it works fine in DEBUG, but when build a release and run
it, it gives me the dialog for an unhandled exception.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top