none
Project builds for .NET 4.0 but not 4.0 Client Profile

    Question

  • Hi,

    I'm converting some class library projects from .NET 2.0 to 4.0. I've gone through the wizard to get the solution and projects into Visual Studio 2010 and it builds. When I open the project properties for any of my class library projects and set the target framework to .NET 4.0 it still builds, but if I change it to .NET 4.0 Client profile, which is what I want, it doesn't. What is confusing me is that the errors are that a referenced namespace in one of my own class libraries doesn't exist.

    E.G.

    I have a class library named IGLT.SMO.Data. Its default namespace is IGLT.SMONET.Data with several classes in that namespace.

    A second class library named Common references IGLT.SMO.Data and uses it throughout. When I change Common to target .NET 4.0 Client Profile I get errors like "The type or namespace 'SMONET' does not exist in the namespace 'IGLT' (are you missing an assembly reference?)".

     

    I'm not missing a reference or it wouldn't build for any framework. What am I missing?

    • Edited by _xr280xr_ Friday, September 3, 2010 9:05 PM Found new information invalidating the original post.
    • Moved by Larcolais Gong Monday, September 6, 2010 7:29 AM (From:.NET Framework Setup)
    Thursday, September 2, 2010 5:46 PM

Answers

  • You can't reference any .NET assembly not present in the Client Profile and you can't reference any of your assemblies that itself references any assembly not present in the Client Profile. Not sure If that's clear, so here's the MSDN quote:

    "If your application targets the .NET Framework 4 Client Profile, you can add a reference to a class library that targets the .NET Framework 4 as long as that library does not reference any assemblies not included in the .NET Framework 4 Client Profile. If the library does include references to assemblies not in the .NET Framework 4 Client Profile, then Visual Studio will display an error message."

    Source: http://msdn.microsoft.com/en-us/library/cc656912.aspx

     

    So I think you should start by making sure that the Data assembly or any of it's dependencies don't reference stuff outside the Client Profile, like ASP.NET stuff or the Oracle Data Provider (knowing that the assembly is named "Data", it's possible you're referencing this .net framework provider).


    -- Blog: http://geeklyeverafter.blogspot.com/
    • Marked as answer by _xr280xr_ Tuesday, September 7, 2010 4:45 PM
    Tuesday, September 7, 2010 4:40 PM

All replies

  • Hi _xr280xr_,

    I'll help you moving your thread into CLR forum.

    You will get more helpful suggestions there.

    Best Regards

    Larcolais Gong


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Monday, September 6, 2010 7:29 AM
  • You should change the "Data" assembly to build to Client Profile before changing the "Common" assembly. Since "Data" is referenced by "Common", if you change "Common" to build using the Client Profile before changing the "Data" assembly it will not work, because an assembly built for the .NET 4 Client Profile can't reference an assembly using the .NET 4.

    If everything else fails try removing all references and re-add them.


    -- Blog: http://geeklyeverafter.blogspot.com/
    Monday, September 6, 2010 12:58 PM
  • Thanks Larcolais and Bruno. I didn't know that, but in the example above, the Data assembly is still on .NET 2.0. If I change it to .NET 4.0 Client Profile, it gets a similar set of errors for a .NET 2.0 class library that it references. Removing and re-adding the references hasn't helped.
    Tuesday, September 7, 2010 3:40 PM
  • You can't reference any .NET assembly not present in the Client Profile and you can't reference any of your assemblies that itself references any assembly not present in the Client Profile. Not sure If that's clear, so here's the MSDN quote:

    "If your application targets the .NET Framework 4 Client Profile, you can add a reference to a class library that targets the .NET Framework 4 as long as that library does not reference any assemblies not included in the .NET Framework 4 Client Profile. If the library does include references to assemblies not in the .NET Framework 4 Client Profile, then Visual Studio will display an error message."

    Source: http://msdn.microsoft.com/en-us/library/cc656912.aspx

     

    So I think you should start by making sure that the Data assembly or any of it's dependencies don't reference stuff outside the Client Profile, like ASP.NET stuff or the Oracle Data Provider (knowing that the assembly is named "Data", it's possible you're referencing this .net framework provider).


    -- Blog: http://geeklyeverafter.blogspot.com/
    • Marked as answer by _xr280xr_ Tuesday, September 7, 2010 4:45 PM
    Tuesday, September 7, 2010 4:40 PM
  • Hmm, not sure what its referencing but there must be something. Too bad the error message complains about namespaces instead of identifying the problem. The Data library uses a custom framework library built around Enterprise Library. That's probably where the problem is. I'm going to just target .Net 4.0. Thanks for your help!

    Tuesday, September 7, 2010 4:45 PM