- Sign In
- Create Account
- View New Content
- Forums
- Members
- Chat
- Netduino Forums
- → General
- → General Discussion
The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
");//]]>
Started by NeonMika / Markus VV., Oct 27 2011 06:43 PM
- Please log in to reply
5 replies to this topic
#1NeonMika / Markus VV.
NeonMika / Markus VV.
- Members
- 209 posts
Advanced Member
- LocationUpper Austria
Posted 27 October 2011 - 06:43 PM
Hey folks,I'm facing a new problem. I have a library, created for "normal" .Net.Now I want to use this library in an .NETMF project and I get the warning message "The project 'NeonMika.Config' cannot be referenced. The referenced project is targeted to a different framework family (.NETFramework)"I expected that and thougt i just could change the framework in the properties page, but this is not working (just can choose from different .Net versions, not .NETMF)In one sentence: Is there an easy way to use an .Net libaray? Greets, Markus
NeonMika.Webserver
> Control your N+ and write webservice methods easyily
> Receive data from you N+ (in XML or JSON)
> Browse the SD on your N+ directly in the browser and down - and upload files
If you need help with NeonMika.Webserver, please just leave a note in the thread and/or contact me via Skype
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
--- Mistakes teach you important lessons. Every time you make one, you are one step closer to your goal. ----
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
- Back to top
#2xprment626
xprment626
- Members
- 6 posts
New Member
Posted 27 October 2011 - 07:42 PM
Hey folks,
I'm facing a new problem. I have a library, created for "normal" .Net.
Now I want to use this library in an .NETMF project and I get the warning message "The project 'NeonMika.Config' cannot be referenced. The referenced project is targeted to a different framework family (.NETFramework)"
I expected that and thougt i just could change the framework in the properties page, but this is not working (just can choose from different .Net versions, not .NETMF)
In one sentence: Is there an easy way to use an .Net libaray?Greets, Markus
Edit: I guess I should ask, do you have sources for this library? If not, ignore everything below :-)
I don't currently have access to a CF project file, but I don't think that there is an automatic way to do this so you might need to manually change the project file to include the appropriate targets, versions, etc. Once you have that building, you will most likely have a bunch of build errors as a result of using methods/classes that may only exist in big .NET which you can fix as you find them. I would use '#if CF' for the fixes so that the project is preserved for big .NET too and makes maintenance easier. I believe you can also conditionally include references/files in the project file (e.g., <Include condition=" '$(someCFIndicator)' = 'true'>MyCFFile.cs</Include>). If I get time tonight I will play around with this and see if I can help some more.
- Back to top
#3NeonMika / Markus VV.
NeonMika / Markus VV.
- Members
- 209 posts
Advanced Member
- LocationUpper Austria
Posted 27 October 2011 - 08:01 PM
Edit: I guess I should ask, do you have sources for this library? If not, ignore everything below :-)
I don't currently have access to a CF project file, but I don't think that there is an automatic way to do this so you might need to manually change the project file to include the appropriate targets, versions, etc. Once you have that building, you will most likely have a bunch of build errors as a result of using methods/classes that may only exist in big .NET which you can fix as you find them. I would use '#if CF' for the fixes so that the project is preserved for big .NET too and makes maintenance easier. I believe you can also conditionally include references/files in the project file (e.g., <Include condition=" '$(someCFIndicator)' = 'true'>MyCFFile.cs</Include>). If I get time tonight I will play around with this and see if I can help some more.
Yes, i have the source code, and it's not very big, but i'm just interested
I know that i just could create a netduino project, copy the cs files into this directory, add this files to the project and compile it. But from this moment on, i would have to maintaince 2 projects (.net and netmf) doing exactly the same...
It would be great if you can give me more information about "manually changing the project file"... Or about this topic in general. I hope you find somd time tonight
But already thanks for your help
NeonMika.Webserver
> Control your N+ and write webservice methods easyily
> Receive data from you N+ (in XML or JSON)
> Browse the SD on your N+ directly in the browser and down - and upload files
If you need help with NeonMika.Webserver, please just leave a note in the thread and/or contact me via Skype
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
--- Mistakes teach you important lessons. Every time you make one, you are one step closer to your goal. ----
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
- Back to top
#4Chris Walker
Chris Walker
- Moderators
- 7767 posts
Secret Labs Staff
- LocationNew York, NY
Posted 27 October 2011 - 08:20 PM
We have a lot of libraries (10,000's or 100,000's of lines code) which we build for .NET MF, .NET CF, and .NET. The .NET CF and .NET assemblies are often one-and-the same, but I find that we end up P/Invoking quite a bit and build "helper" libraries to fill in missing features in .NET CF...so we tend to build multiple projects for simplicity sake.In theory, you should be able to build one project and switch between configurations to build it for .NET MF vs. .NET. Assuming that Visual Studio understands how to target different frameworks for different project configurations. Very interesting indeed.Chris
- Back to top
#5xprment626
xprment626
- Members
- 6 posts
New Member
Posted 27 October 2011 - 08:31 PM
We have a lot of libraries (10,000's or 100,000's of lines code) which we build for .NET MF, .NET CF, and .NET.
The .NET CF and .NET assemblies are often one-and-the same, but I find that we end up P/Invoking quite a bit and build "helper" libraries to fill in missing features in .NET CF...so we tend to build multiple projects for simplicity sake.
In theory, you should be able to build one project and switch between configurations to build it for .NET MF vs. .NET. Assuming that Visual Studio understands how to target different frameworks for different project configurations. Very interesting indeed.
Chris
You could create different configurations and condition on that configuration.
<Import condition=" '$(Configuration)' != 'CF' " Project="Microsoft.Common.Targets" /><Import condition=" '$(Configuration)' == 'CF' " Project="Microsoft.CompactFramework.Common.Targets" />
and include any special files and references similarly. I think you'd have to code this up manually at first. I've mostly seen people creating separate project files, but the conditional approach should work.
Again, if I have time tonight, I'll try to create a template (not of the VS variety) for this.
- Back to top
#6xprment626
xprment626
- Members
- 6 posts
New Member
Posted 28 October 2011 - 04:11 AM
Ok, this is very rough, but joining both types of projects, you get something like the code below. You will have to tweak it as you go, but I think this demonstrates the point. The advantage of maintaining two project files is that you get better tooling support.
<?xml version="1.0" encoding="utf-8"?><Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup Label="Common Properties"> <Configuration Condition=" '$(Configuration)' == '' ">Release</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <RootNamespace>MyLibrary</RootNamespace> <AssemblyName>MyLibrary</AssemblyName> <OutputType>Library</OutputType> <SchemaVersion>2.0</SchemaVersion> <ProjectGuid>{340BCCC0-3F98-40E7-8DBD-181954F999F2}</ProjectGuid> <AppDesignerFolder>Properties</AppDesignerFolder> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugType>pdbonly</DebugType> <Optimize>true</Optimize> <OutputPath>bin\Release\</OutputPath> <DefineConstants>TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> </PropertyGroup> <PropertyGroup Label="CF Properties" Condition=" '$(Configuration)|$(Platform)' == 'CompactFramework|AnyCPU' "> <DebugType>pdbonly</DebugType> <Optimize>true</Optimize> <OutputPath>bin\Release\</OutputPath> <DefineConstants>TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <OutputPath>bin\CompactFramework\</OutputPath> <TargetFrameworkVersion>v4.1</TargetFrameworkVersion> <ProductVersion>9.0.21022</ProductVersion> <ProjectTypeGuids>{b69e3092-b931-443c-abe7-7e7b65f2a37f};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> <NetMfTargetsBaseDir Condition="'$(NetMfTargetsBaseDir)'==''">$(MSBuildExtensionsPath32)\Microsoft\.NET Micro Framework\</NetMfTargetsBaseDir> </PropertyGroup> <PropertyGroup Label="dotNET Properties" Condition=" '$(Configuration)' != 'CompactFramework' "> <TargetFrameworkVersion>v4.0</TargetFrameworkVersion> <ProductVersion>8.0.30703</ProductVersion> <FileAlignment>512</FileAlignment> </PropertyGroup> <Import Condition=" '$(Configuration)' == 'CompactFramework' " Project="$(NetMfTargetsBaseDir)$(TargetFrameworkVersion)\CSharp.Targets" /> <ItemGroup Label="Common References"> </ItemGroup> <ItemGroup Label="Common Files"> <Compile Include="MyClass.cs" /> </ItemGroup> <ItemGroup Condition=" '$(Configuration)' != 'CompactFramework' "> <Compile Include="NET.cs" /> </ItemGroup> <ItemGroup Condition=" '$(Configuration)' == 'CompactFramework' "> <Compile Include="CF.cs" /> </ItemGroup> <Import Condition=" '$(Configuration)' != 'CompactFramework' " Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /></Project>
- Back to top
Back to General Discussion
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users
- Netduino Forums
- → General
- → General Discussion
- Privacy Policy
homehardwareprojectsdownloadscommunitywhere to buycontact | Copyright © 2016 Wilderness Labs Inc.| Legal | |