-1

I am trying to load a form class from a program running as a tray icon that originally used

FileList frmFileList = new FileList();

Now instead of a filelist I want to use a custom form but I get the error:

Error 1 'System.Windows.Forms.Control.ControlCollection' does not contain a definition for 'Cast' and no extension method 'Cast' accepting a first argument of type 'System.Windows.Forms.Control.ControlCollection' could be found (are you missing a using directive or an assembly reference?)

Any ideas?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
DOSrelic
  • 1
  • 1
  • 2

2 Answers2

1

It sounds like you forgot using System.Linq; at the top of your source file. But since you didn't post the sources, I can't say for sure. Posting the line of code that causes the error message, and the using directives that are in that same file would help.

cdhowie
  • 158,093
  • 24
  • 286
  • 300
0

Are you sure you are not trying something like this?

FileList frmFileList = new SomethingDifferent();

If so, change the FileList on the left side to SomethingDifferent.

Pabuc
  • 5,528
  • 7
  • 37
  • 52
  • FileList frmFileList = new FileList(); IT WAS and now I tried DOScharForm Dform = new DOScharForm(); So what's the diff? – DOSrelic Dec 31 '10 at 08:12
  • @user559057: It's not a message board or forum. It's a Q&A site. – cdhowie Dec 31 '10 at 08:26
  • Yes cdhowie but the difference makes it hard to make sense of my questions. I am having trouble in Csharp with enacting a form from a program that appears to require a comand line text rendering basis? The calsls are: – DOSrelic Dec 31 '10 at 09:07
  • Are you saying that you are trying to instantiate a form object in a console application? That doesn't make any sense – Pabuc Dec 31 '10 at 09:26
  • The Error System.Windows.Forms.Control.ControlCollection' does not contain a definition for 'Cast' and no extension method 'Cast' accepting a first argument of Type 'System.Windows.Forms.Control.ControlCollection' could be found...from: foreach (var child in c.Controls.Cast()) { DisableCompatibleTextRendering(child); } } I think my problem stems from trying to utilise/adapt VB code in a Csharp program? The line generating the error= foreach (var child in c.Controls.Cast()){ DisableCompatibleTextRendering(child);}} ?[var child]?+no cast is known for that call in Csharp? – DOSrelic Dec 31 '10 at 09:27
  • !!!AHA!!! Shift enter for a new line! lol My apologies for my 'newbie' approach and thanks for your guys' attention. – DOSrelic Dec 31 '10 at 09:28