Extensions in Program not in Assembly

JaedenRuiner

Well-known member
Joined
Aug 13, 2007
Messages
340
Programming Experience
10+
Okay, so i have two projects. one is my application, the other is an Assembly I've been working on, in some ways reinventing the wheel, but in others providing that particular brand of functionality I normally use all the time and hate having to re-write. You know, for Generic Collections and allow a built in sort function, or other event driven notifications that are not always used but when needed they are so nice that i don't have to re-write them.

However, a perfect example of the issues i'm having between the app and the assembly dll is that certain extensions don't work.

for example the .Cast extension that seems to work on every ICollection implementation (or maybe it's IEnumerble) but that is of little concern.

In my App I can do this:

My.Settings.Properties.Cast(Of Configuration.SettingsProperty).ToArray and voila it works.

When I try the same thing in the Assembly DLL I get:
'Cast' is not a member of 'SettingsPropertyCollection'

So what reference do i need to add to get that thing to work?

thanks
 
Those extensions work in a default Class Library project, it is possible you have removed any of the default references or imports?
F1 key says it is part of System.Linq namespace from System.Core.dll assembly, by the way.
 
Odd,


Because the System.Core is in my references for the assembly project, and funnily enough, when I add "Imports System.Linq" to the source file I suddenly can use those extensions, but without the Import line they don't work.

ooh...I did initially create this project in VS2005, not 2008, I imported it to 2008 and haven't gone back. Linq isn't part of '05, so that might be the issue. If so, is there a way to go in and resolve it? (other than just recreating the whole library?)

Thanks
 
Try changing the the target framework from .Net 2.0 to .Net 3.5, when you upgrade a project from VS 2005 to VS 2008, VS 2008 assumes you still want it to target the 2.0 framework.
 
Well, the answer came but as a matter of indirection..

I had already changed the Target Framework to 3.5, however, that did not automatically update the Project Imported namespaces: (VS2008: Project Options|References Tab)

When I looked in there the only differece (other than the intended ones) between my app and teh assembly was that my Assembly was not importing System.Linq

I've added that into the Project references and all is hunky dory.

Thanks
 
Back
Top