- Created a new
Class Library (Package)
project - Changed the
project.json
to look like this (added project dependencies):
project.json
{
"version": "1.0.0-*",
"description": "WMI.ECM.PCMS.Services.Acomba Class Library",
"authors": [ "WILL" ],
"tags": [ "" ],
"projectUrl": "",
"licenseUrl": "",
"dependencies": {
"Acomba.SDK": "2.0.0",
"WMI.ECM.Inventory.Models": "",
"WMI.ECM.Inventory.Services": "",
"WMI.ECM.Inventory.Services.Contracts": ""
},
"frameworks": {
"dnx451": { },
"dnxcore50": {
"dependencies": {
"Microsoft.CSharp": "4.0.1-beta-23516",
"System.Collections": "4.0.11-beta-23516",
"System.Linq": "4.0.1-beta-23516",
"System.Runtime": "4.0.21-beta-23516",
"System.Threading": "4.0.11-beta-23516"
}
}
}
}
- Compiled the solution, and I get this error:
The type 'DateTime' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PunlicKeyToken=b77a5c561934e089'.
- Yet, I do not have this problem with my other projects which also target DNX451 and DNXCORE50. Also shall I mention that the
mscorlib.dll
is actually referenced in the project in question per this screenshot:Referenced assemblies
.
As a result, I did some searches which end up clueless.
I tried to add dependencies to the dnx451{} in my project.json like so:
"dnx451": {
"dependencies": {
"Microsoft.CSharp": "",
"System.Runtime": ""
...
}
}
Because I remember having read such a solution somewhere, and it didn't work.
Most of the answers are for an older version of a web project which solve it by adding a reference in the
web.config
. Well,Class Library (Package)
has noweb.config
.I also downloaded and installed this patch:
Microsoft .NET Framework 4.5.2 Developer Pack
, which changed nothing.And another one which I can barely understand what is discussed because they are talking about the facades for each and every version of the framework or something like it.
It looks like a common problem although I can't find any helpful solution to the actual problem.
Currently using
- Visual Studio Community 2015 - Version 14.0.25123.00 Update 2
- .NET Framework 4.6.01055
- ASP.NET MVC 6 Installed
- SideWaffle for Xunit DNX Unit Test Project Template
- Visual C# 2015
UPDATE
It appears to be caused by the COM library which I imported using this tool from the VS CMD line: Tlbimp.exe (Type Library Importer)
.
In short, the AcoSDK.dll is a COM library which I imported using the above-mentioned tool to create a .NET assembly with all the COM types resolved as .NET types.
Then, I used NuGet.exe
to create a package which I published over my private feed.
And then, I referenced the package in my project as "Acomba.SDK": "2.0.0"
in my project.json
.
Whenever I use a DateTime property from this package, the build error occurs. For example, this causes the error to occur:
public DateTime CreatedAt { get { return p.PrTimeModified; } }
And this doesn't:
public DateTime CreatedAt { get { return new DateTime(); } }
The COM type for a .NET DateTime is Date. However, it's supposed to be seen as a DateTime following the steps in the examples provided on the tlbimp.exe
command line.
It is only when I added a dot to the property that I saw that the DateTime was not supported in DNXCORE50. Except that it is for native DateTime such as 'new DateTime()' (see screenshot here
).
Any clue as to how to workaround this?