2

Hi I'm using Win7 64x and Visual Studio 2010. I created a library/framework targeting Any CPU. Then I created a new WinForms project that uses that framework, leaving the default values of the wizard. I mean, I didn't change anything. When I reference my framework, VS cannot find the assemblies. If I go to the project properties, it is targeting Any CPU (as expected, I can change it if I want). But if I go to Configuration Manager, the only choice I have for that project is x86. And I guess that is the problem. I tried to add Any CPU as a new Target but I was unable to.

Could someone help me? :)

Thanks in advance!

ivos
  • 21
  • 1
  • "cannot find assemblies". We need a better error message for that. "but I was unable to" is similarly vague, describe *exactly* what goes wrong. – Hans Passant Dec 26 '10 at 15:55
  • Agreed, it would help to know if the library is in the GAC, how you are referencing the assembly (did you try browsing to the compiled dll?), etc. Basically, we need more information. – John Dec 26 '10 at 16:03
  • Did you add the project/assembly reference beforehand? – Machinarius Dec 26 '10 at 16:40
  • Thanks for our quick responses! I referenced the compiled assemblies not from the gac but from a "lib" folder containing all the assemblies. The reference are in the project, but it fails saying "System.IO.FileNotFoundException: Could not load file or assembly". I know this is a common problem when referenging between different platforms. When I go to "Configuration Manager", for that winforms app I have the choise "x86", "" and "". – ivos Dec 26 '10 at 16:44
  • Chosing new and edit only let me copy from x86 and not Any CPU, and if I choose empty and try to use the name "Any CPU", it tells me that there's already a target with that name. – ivos Dec 26 '10 at 16:48
  • I will add an example of when the error cames out: When I use something from my framework in a class and I try to build the solution, it fails saying that it cannot find my framework's assembly. – ivos Dec 26 '10 at 16:52
  • You should get points for sticking with it but I'm afraid it's still quite unclear what you mean. In Configuration Manager you should see both an 'Active solution configuration' and an 'Active solution platform.' The name of the Active solution configuration is only for your reference. The Active solution platform can make a big difference. Can you clarify which says Any CPU? Also, confirm your framework is a dll written in .Net. – John Dec 27 '10 at 06:03
  • My framework is a dll written in .Net and build for AnyCPU. Active Solution Platform: Mixed Platform (I also tried Any CPU without success) In the project context, the WinformsApplication's platform is x86. – ivos Dec 27 '10 at 12:46
  • If I edit the csproj file and change it to anycpu, it continue blaming about not finding the types in the referenced assembly. If I create a ClassLibrary and then I change the Output Type to Windows Application, it works fine; the problem is for new Windows Applications in VS2010. Also, I would like to avoid this workaround, but at least I'm not stopped. Thanks – ivos Dec 27 '10 at 13:19
  • How about trying a simple repro test. Start VS, create a new C# 4.0 WinForms project, set the active platform to x86, add a reference to your dll, add a click event to form1, and in that event add a simple call to your dll (the simpler the better). Then compile and try to write a detailed response of when and where you see errors. I just did it here - referencing a dll set to any cpu - and it worked without a problem. – John Dec 28 '10 at 06:53

1 Answers1

0

Have you tried creating a new platform for your project in the configuration manager and unchecking the 'Create new solution platforms' option? EDIT: Change both the configuration manager and target platform to Any CPU. Have a look at this SO question for more details.

Community
  • 1
  • 1
Raheel Khan
  • 14,205
  • 13
  • 80
  • 168