Reputation: 570
I have a quite obscure problem with assemblies in mvc6. Just today I installed ASP.NET beta 7 ( from here: beta http://www.microsoft.com/en-us/download/details.aspx?id=48738&fa43d42b-25b5-4a42-fe9b-1634f450f5ee=True) and mvc 6 for my solution (via a nuget command: Install-Package Microsoft.AspNet.Mvc -Pre ), everything worked fine before I added some references like Microsoft.VisualBasic or System.Drawing. Now I get ,,the type or namespace name could not be found" for all of them. I am pretty confident that I added the referencies to the assemblies. Anyone else encountered this issue ? Tried creating a new project and adding the same references- same problem. Also, intellisense is working fine, it has problems with references only at build-time.
UPD: here is the project.json
{
"webroot": "wwwroot",
"version": "1.0.0-*",
"dependencies": {
"Microsoft.AspNet.Mvc": "6.0.0-beta7",
"Microsoft.AspNet.Server.IIS": "1.0.0-beta7",
"Microsoft.AspNet.Server.WebListener": "1.0.0-beta7"
},
"commands": {
"web": "Microsoft.AspNet.Hosting --config hosting.ini"
},
"frameworks": {
"dnx451": {
"dependencies": {
"SpreadsheetGear2012.Core": "1.0.0-*",
"SpreadsheetGear2012.Drawing": "1.0.0-*"
},
"frameworkAssemblies": {
"Microsoft.VisualBasic": "10.0.0.0",
"System.Drawing": "4.0.0.0"
}
},
"dnxcore50": { }
},
"publishExclude": [
"node_modules",
"bower_components",
"**.xproj",
"**.user",
"**.vspscc"
],
"exclude": [
"wwwroot",
"node_modules",
"bower_components"
]
}
Upvotes: 3
Views: 599
Reputation: 21897
The issue is that you are targeting both dnx451
and dnxcore50
but only add a dependency to System.Drawing
and Microsoft.VisualBasic
in dnx451
. When you compile, it doesn't know how to resolve the System.Drawing
and Microsoft.VisualBasic
namespaces when compiling against dnxcore50
. To resolve it, you can either:
Remove the target to dnxcore50
in your project.json
:
"frameworks": {
"dnx451": {
"dependencies": {
"SpreadsheetGear2012.Core": "1.0.0-*",
"SpreadsheetGear2012.Drawing": "1.0.0-*"
},
"frameworkAssemblies": {
"Microsoft.VisualBasic": "10.0.0.0",
"System.Drawing": "4.0.0.0"
}
}
},
or compile with #if DNX451
wherever you use System.Drawing
or Microsoft.VisualBasic
:
public void MyMethod()
{
#if DNX451
var bmp = new System.Drawing.Bitmap("file");
#endif
}
Upvotes: 8