Last post Aug 03, 2014 01:38 PM by P4tr1k
None
0 Points
9 Posts
Jul 17, 2014 06:00 AM|P4tr1k|LINK
Hey *,
My goal is to add a reference of my ASP.NET vNext project to the NET 4.5 MySql.Data DLL from oracle.
I read that this should be possible.
I put it to in a NuGet package, compiled it successfully after add to project.json, but cant use it in my classes. Anything there is wrong.
Is there a guideline how to add dll DLL references? I searched a lot until now, but haven't had found anything.
Best regards
All-Star
33953 Points
8478 Posts
MVP
Jul 19, 2014 03:35 PM|imran_ku07|LINK
Yes VNext is package base. You can add MySql.Data package in your project.json inside net45 dependencies instead of root dependencies, for example,
{ "dependencies": { "EntityFramework.SqlServer": "7.0.0-alpha2", "Microsoft.AspNet.Mvc": "6.0.0-alpha2", "Microsoft.AspNet.Identity.EntityFramework": "3.0.0-alpha2", "Microsoft.AspNet.Identity.Authentication": "3.0.0-alpha2", "Microsoft.AspNet.Security.Cookies": "1.0.0-alpha2", "Microsoft.AspNet.Server.IIS": "1.0.0-alpha2", "Microsoft.AspNet.Server.WebListener": "1.0.0-alpha2", "Microsoft.AspNet.StaticFiles": "1.0.0-alpha2", "Microsoft.Framework.ConfigurationModel.Json": "1.0.0-alpha2", "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0-alpha2" }, "commands": { /* Change the port number when you are self hosting this application */ "web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --server.urls http://localhost:5000" }, "configurations": { "net451" : { "dependencies": { "MySql.Data -Version": "6.7.5" } }, "k10" : { } } }
and then you can write your net451 specific code as
#if NET45 // Here #endif
The reason is that VS targets both k10 and net451 when you build your app. See this link for details,
http://stackoverflow.com/questions/24215284/cannot-add-nuget-packages-to-asp-net-vnext-project
Aug 01, 2014 05:39 AM|P4tr1k|LINK
Thanks for great, comprehensive response.
I can compile my project now, but cannot switch to the .NET 4.5 mode so that he don't jumps into the
#if NET45
area.
Any idea or is it perhaps a early bug? I'm using the CTP 14.0.21901.1DP version.
Project Properties: Configuration: Debug Active Target Framework: .NET Framework 4.5.1
Contributor
2292 Points
908 Posts
Microsoft
Aug 03, 2014 04:39 AM|davidfowl|LINK
Does your project.json have net451 or net45?
Aug 03, 2014 01:38 PM|P4tr1k|LINK
net451. I switched to 45 but it hasn't had no effect.
With the NuGet packaging tool I retrieve the following message:
'MySql.Data' could not be installed because it is not be compatible with any projects in your solution.
The package targets the following frameworks:
2.0 - 4.5
Now I have 4.5.1 due to cannot compile with 4.5. But the DLL has to be backward compatible right?
None
0 Points
9 Posts
Add .NET 4.5 Assembly As Reference
Jul 17, 2014 06:00 AM|P4tr1k|LINK
Hey *,
My goal is to add a reference of my ASP.NET vNext project to the NET 4.5 MySql.Data DLL from oracle.
I read that this should be possible.
I put it to in a NuGet package, compiled it successfully after add to project.json, but cant use it in my classes. Anything there is wrong.
Is there a guideline how to add dll DLL references?
I searched a lot until now, but haven't had found anything.
Best regards
All-Star
33953 Points
8478 Posts
MVP
Re: Add .NET 4.5 Assembly As Reference
Jul 19, 2014 03:35 PM|imran_ku07|LINK
Yes VNext is package base. You can add MySql.Data package in your project.json inside net45 dependencies instead of root dependencies, for example,
{ "dependencies": { "EntityFramework.SqlServer": "7.0.0-alpha2", "Microsoft.AspNet.Mvc": "6.0.0-alpha2", "Microsoft.AspNet.Identity.EntityFramework": "3.0.0-alpha2", "Microsoft.AspNet.Identity.Authentication": "3.0.0-alpha2", "Microsoft.AspNet.Security.Cookies": "1.0.0-alpha2", "Microsoft.AspNet.Server.IIS": "1.0.0-alpha2", "Microsoft.AspNet.Server.WebListener": "1.0.0-alpha2", "Microsoft.AspNet.StaticFiles": "1.0.0-alpha2", "Microsoft.Framework.ConfigurationModel.Json": "1.0.0-alpha2", "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0-alpha2" }, "commands": { /* Change the port number when you are self hosting this application */ "web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --server.urls http://localhost:5000" }, "configurations": { "net451" : { "dependencies": { "MySql.Data -Version": "6.7.5" } }, "k10" : { } } }and then you can write your net451 specific code as
#if NET45 // Here #endifThe reason is that VS targets both k10 and net451 when you build your app. See this link for details,
http://stackoverflow.com/questions/24215284/cannot-add-nuget-packages-to-asp-net-vnext-project
Excellent Windows VPS Hosting
Imran Baloch MVP, MVB, MCP, MCTS, MCPD
None
0 Points
9 Posts
Re: Add .NET 4.5 Assembly As Reference
Aug 01, 2014 05:39 AM|P4tr1k|LINK
Thanks for great, comprehensive response.
I can compile my project now, but cannot switch to the .NET 4.5 mode so that he don't jumps into the
#if NET45
area.
Any idea or is it perhaps a early bug? I'm using the CTP 14.0.21901.1DP version.
Project Properties:
Configuration: Debug
Active Target Framework: .NET Framework 4.5.1
Contributor
2292 Points
908 Posts
Microsoft
Re: Add .NET 4.5 Assembly As Reference
Aug 03, 2014 04:39 AM|davidfowl|LINK
Does your project.json have net451 or net45?
Principal SDE, ASP.NET Team, Microsoft
None
0 Points
9 Posts
Re: Add .NET 4.5 Assembly As Reference
Aug 03, 2014 01:38 PM|P4tr1k|LINK
net451. I switched to 45 but it hasn't had no effect.
With the NuGet packaging tool I retrieve the following message:
'MySql.Data' could not be installed because it is not be compatible with any projects in your solution.
The package targets the following frameworks:
2.0 - 4.5
Now I have 4.5.1 due to cannot compile with 4.5. But the DLL has to be backward compatible right?