当前位置:网站首页>.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 思考
多点一下,确认。
边栏推荐
- Winter messenger 2
- Bash exercise 17 writing scripts to install the server side of FRP reverse proxy software
- cgroup_ memcg
- GDB code debugging
- How to answer when you encounter a jet on CSDN?
- TypeScript入门
- H5 模块悬浮拖动效果
- 在新线程中使用Handler
- 1. Create Oracle database manually
- [Gaode map POI stepping pit] amap Placesearch cannot be used
猜你喜欢

Design specification for mobile folding screen

5. Oracle TABLESPACE

2. Addition and management of Oracle data files

Alibaba established the enterprise digital intelligence service company "Lingyang" to focus on enterprise digital growth

LSA Type Explanation - detailed explanation of lsa-2 (type II LSA network LSA) and lsa-3 (type III LSA network Summary LSA)

Record of problems in ollvm compilation

MPLS experiment

MPLS experiment

Positive height system

论文阅读报告
随机推荐
GDB code debugging
20220213-CTF MISC-a_ good_ Idea (use of stegsolve tool) -2017_ Dating_ in_ Singapore
Using handler in a new thread
Database mysql all
数据库Mysql全部
安装OpenCV--conda建立虚拟环境并在jupyter中添加此环境的kernel
Day 2 document
Dataframe (1): introduction and creation of dataframe
Vscode creates its own code template
Pycahrm reports an error: indentation error: unindent does not match any outer indentation
Vscode configures the typera editor for MD
MPLS experiment
Idea debug failed
kata container
求组合数 AcWing 889. 满足条件的01序列
LSA Type Explanation - lsa-5 (type 5 LSA - autonomous system external LSA) and lsa-4 (type 4 LSA - ASBR summary LSA) explanation
Filter the numbers and pick out even numbers from several numbers
Bash exercise 17 writing scripts to install the server side of FRP reverse proxy software
3. Oracle control file management
La redirection de l'applet Wechat ne déclenche pas onload