简体   繁体   中英

How to reference .net 4 class library from .net core

I am using VS 2015 Update 3. I added reference in my .net core project but I can't access to methods/members/classes. 在此处输入图片说明

在此处输入图片说明

在此处输入图片说明

Since you have added Service4 class library reference only in .NET 4.0 dependencies section (refer below snapshot), You need to use Conditional Compilation.

NET40依赖项

To access, Service4 members, you need to do like this-

#if NET40 
    Service4.Test.PrintHi(); 
#endif

These are list of preprocessor symbols used in #if directives:

.NET Framework 2.0 --> NET20

.NET Framework 3.5 --> NET35

.NET Framework 4.0 --> NET40

.NET Framework 4.5 --> NET45

.NET Framework 4.5.1 --> NET451

.NET Framework 4.5.2 --> NET452

.NET Framework 4.6 --> NET46

.NET Framework 4.6.1 --> NET461

.NET Framework 4.6.2 --> NET462

.NET Standard 1.0 --> NETSTANDARD1_0

.NET Standard 1.1 --> NETSTANDARD1_1

.NET Standard 1.2 --> NETSTANDARD1_2

.NET Standard 1.3 --> NETSTANDARD1_3

.NET Standard 1.4 --> NETSTANDARD1_4

.NET Standard 1.5 --> NETSTANDARD1_5

.NET Standard 1.6 --> NETSTANDARD1_6

For more details, refer this article

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM