I have an application that, on occasion, might need to perform certain tasks on files, or other things that are "in-use" while the application in running.

This is what I've tried to do, but I'm running into problems:

I created an interface:

interface IShutdownCommand
    {
        void OnShutdown();
    }

I wanted to create, on my main application window code the following:

//initialize shutdown Commands
        public List<IShutdownCommand> ShutdownCommandList;

        private void Main_FormClosing(object sender, FormClosingEventArgs e)
        {
                foreach (IShutdownCommand Command in ShutdownCommandList)
                {
                    Command.OnShutdown();
                }
        }

But I'm getting this compiler error:

"Inconsistent accessibility: field type 'System.Collections.Generic.List<DATA.IShutdownCommand>' is less accessible than field 'DATA.Main.ShutdownCommandList'"

Any thoughts on how I could do this and actually get it to work?

Your interface is less accessible than your field. Put 'public' in front of the interface declaration.

What this is telling you is that you are trying to declare a publicly available variable (ShutdownCommandList) that uses something that isn't publicly available (IShutdownCommand).

Ahhh...duh...thanks for the obvious.

It's going to be one of those weeks...I can tell.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.