当前位置:网站首页>.net core踩坑实践
.net core踩坑实践
2022-07-05 06:26:00 【艾萨克SU】
.net core踩坑
0.错误提示
准确的说是有两个坑,一个关于.net core的版本,另一个关于编译选项的。先贴一下错误信息。
0.1打不开工程
第一个错误就是打不开工程,我装的VS2017,打开一个现有工程时,报错Project file is incomplete. Expected imports are missing
可是这个工程是git库里的,产品都是用的这个。为什么我本地就打不开呢?
0.2 项目无法加载
同样的环境,另一个工程,里面有一个project,在打开sln之后,这个project显示未正常加载,在error list中提示:
Error NU1105 Unable to find project information - The project file may be invalid or missing targets required for restore
而且只有这一个项目是无法加载的,sln中其他可以。
0.3 System.BadImageFormatException
这个问题是在前面的问题解决之后,终于能够打开编译了,可是运行起来却在某个地方报了个错误,就是这个System.BadImageFormatException
1 第一个坑
1.1 VS版本
经过咨询同事,他也没找到原因,但是他问了我一句你没装vs2019啊。我就试着装上了vs2019,然后就发现vs2019能够打开这个项目,一切正常,再次用vs2017就打不开。
1.2 .net core版本
搜索了一下,有些人提是.net core的原因。重新查看了安装环境的说明,里面要求按照.net core 2.1, 我查了,确实是.net core 2.1啊。
后来终于查到了一个关键的地方。
https://stackoverflow.com/questions/49432666/project-file-is-incomplete-expected-imports-are-missing
和
https://stackoverflow.com/questions/53329290/net-core-2-2-cant-be-selected-in-visual-studio-build-framework/55529011#55529011
看说明:
Issue details: 2.1.6xx & 2.2.2xx version of the sdks are only supported on Visual Studio 2019. VS 2017 needs 2.1.5xx & 2.2.1xx versions of the sdk.
再查看我安装的.net core版本2.1.818,再看看.net core 2.1的下载界面
上面的2.1.818的visual studio support写的是2019, 下面的2.1.526才是支持vs2017的。
卸载2.1.818,安装2.1.526, VS2017能正常打开工程了。
上面0.1和0.2的问题都解决了。
2.第二个坑
2.1 x86
编译成功,调试,可是在跑到一个调用另一个库的地方抛出了异常,就是这个System.BadImageFormatException,搜索发现,通常都是由于X86和X64的库混用导致的。我知道其他库使用的X86,我看了一下我编译时候选择的平台,是X86啊
2.2发现端倪
后来是怎么发现的问题呢?我在attach to process的时候,发现有一列type没有显示全,我把这一列拖宽,显示全了,赫然写着managed(V4.0.3xxx) X64.
怎么回事,我选的是x86啊,
点了一下configure manager,
太有欺骗性了,active solution platform选的是x86,可是各个项目却选的是any cpu,所以最后编出来的是x64 的。
改成x86,重新编译。成功。
3 思考
多点一下,确认。
边栏推荐
- 2. Addition and management of Oracle data files
- Database mysql all
- How to answer when you encounter a jet on CSDN?
- 博弈论 AcWing 892. 台阶-Nim游戏
- TypeScript入门
- 求组合数 AcWing 889. 满足条件的01序列
- The problem of Chinese garbled code in the vscode output box can be solved once for life
- Redis-01. First meet redis
- Dameng database all
- 求组合数 AcWing 888. 求组合数 IV
猜你喜欢
3. Oracle control file management
Game theory acwing 893 Set Nim game
cgroup_ memcg
20220213-CTF MISC-a_ good_ Idea (use of stegsolve tool) -2017_ Dating_ in_ Singapore
达梦数据库全部
Vant Weapp SwipeCell设置多个按钮
Game theory acwing 891 Nim games
What is socket? Basic introduction to socket
Utf8 encoding
[QT] QT multithreading development qthread
随机推荐
FFmpeg build下载(包含old version)
Markdown syntax
安装OpenCV--conda建立虚拟环境并在jupyter中添加此环境的kernel
TCP's understanding of three handshakes and four waves
our solution
ollvm编译出现的问题纪录
June 29, 2022 daily
Winter messenger 2
博弈论 AcWing 892. 台阶-Nim游戏
Game theory acwing 891 Nim games
3.Oracle-控制文件的管理
Vscode editor
博弈论 AcWing 891. Nim游戏
Redis-01.初识Redis
namespace
6-4 search by serial number of linked list
Bash exercise 17 writing scripts to install the server side of FRP reverse proxy software
达梦数据库全部
Written examination notes
Ffmpeg build download (including old version)