-
Sep 30th, 2021, 04:36 AM
#1
Thread Starter
Fanatic Member
-
Sep 30th, 2021, 04:54 AM
#2
Re: NET 5.0 got DllImport CS0246 error
So when you showed potential fixes, as instructed by Intellisense, what did it suggest?
-
Sep 30th, 2021, 05:39 AM
#3
Re: NET 5.0 got DllImport CS0246 error
Originally Posted by DaveDavis
First touch NET 5.0, but I got CS0246 error, don't know what is the reason.
Refer to screenshot.
If this is a .NET Core Console App or WPF, the System.Runtime.InteropServices namespace is listed in Dependencies->Frameworks->Microsoft.NETCore.App, so you should be able to use the DllImport attribute class.
Otherwise, the DllImport could be misspelled.
- kgc
-
Sep 30th, 2021, 08:14 AM
#4
Thread Starter
Fanatic Member
Re: NET 5.0 got DllImport CS0246 error
Intellisense is nothing when I am keying in DllImport; The NET Core is different from Winform NETFramework...But sure something is wrong with what I am doing...
-
Sep 30th, 2021, 08:26 AM
#5
Re: NET 5.0 got DllImport CS0246 error
If System.Runtime.InteropServices is listed under Microsoft.NETCore.App, but errors occur when referencing these classes, then there must be something wrong with the Visual Studio IDE. I tried adding DllImport attribute in .NET Core Winforms project Form1 class without error(s).
-
Sep 30th, 2021, 09:03 AM
#6
Re: NET 5.0 got DllImport CS0246 error
Originally Posted by DaveDavis
Intellisense is nothing when I am keying in DllImport
Ugh. Look at the screenshot you provided in post #1. See the Intellisense popup? See how it provides the option to show potential fixes? Maybe you should use that.
-
Sep 30th, 2021, 07:19 PM
#7
Thread Starter
Fanatic Member
Re: NET 5.0 got DllImport CS0246 error
OK.
I recreate the project, then I see DllImport is intellisensed.
First touching NET CORE gives me a lesson, but it is good to learn something. Thank you everyone.
Edited: I replace the *.csproj with the new one, the problem also goes away.
Last edited by DaveDavis; Sep 30th, 2021 at 08:47 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|