简体   繁体   English

如何运行降级到.Net 4.0的混合C#/ CLR / C ++解决方案?

[英]How to run mixed C#/CLR/C++ solution downgraded to .Net 4.0?

I have solution with mixed projects: C#, native C++ and CLR/C++ (this also requires some external DLLs). 我有混合项目的解决方案:C#,本机C ++和CLR / C ++(这也需要一些外部DLL)。 When I used default settings of VS 2012 and targeted for .Net 4.5 it worked fine. 当我使用VS 2012的默认设置并以.Net 4.5为目标时,它工作正常。 But then I had to downgrade it to .Net 4.0. 但是后来我不得不将其降级为.Net 4.0。

I succeed by building solution only for 32-bit and forcing C# main project to be built for 32-bit also (usually C# is used for "Any CPU"). 我通过仅为32位构建解决方案并强制也为32位构建C#主项目而成功(通常C#用于“任何CPU”)。

With such settings in runs fine on 2 computers out of 3 I have for tests -- meaning on it fails. 有了这样的设置,我可以在3台计算机中的2台计算机上运行正常,这意味着它会失败。 It claims it cannot load CLR/C++ project or one of it dependencies. 它声称它无法加载CLR / C ++项目或它的依赖项之一。

So my problem is how to run it or at least to know what failed exactly ? 所以我的问题是如何运行它,或者至少知道到底是什么失败 From the list of installed programs I can see that on working computer I have either .Net 4.5 Multi-Target or I don't have .Net 4.5 at all (only 4.0). 从已安装程序的列表中,我可以看到在运行的计算机上,我具有.Net 4.5 Multi-Target或根本没有.Net 4.5(仅4.0)。 On computer which fails I have .Net 4.5 (period). 在失败的计算机上,我有.Net 4.5(句号)。 So maybe my program tries to load some assemblies from .Net 4.5 instead of 4.0? 因此,也许我的程序尝试从.Net 4.5而不是4.0加载某些程序集? But that is just guessing. 但这只是猜测。

Question -- how to diagnose such twisted solution and how to fix it? 问题-如何诊断这种扭曲的解决方案以及如何解决?

  1. Install .Net framework 4.0 multi-targeting pack 安装.Net Framework 4.0多目标包
  2. Check references (including NuGet, if any) 检查引用(包括NuGet,如果有的话)

When I encounter a similar problem I usualy check the following: 当我遇到类似的问题时,我通常会检查以下内容:

  1. Do you have Visual Studio installed on any of those three machines? 您是否在这三台计算机中的任何Visual Studio台上安装了Visual Studio I guess it's installed on the two where your application is running. 我猜它安装在运行应用程序的两个位置上。 If so, I'll extend the list later. 如果是这样,我将在以后扩展该列表。

  2. Check the target of the C++/CLI project - it should be Win32 if you build for 32-bit. 检查C++/CLI项目的目标-如果是32位版本,则应为Win32

  3. Run the application without Visual Studio , wait until it fails and go to the Event Viewer to look for some usefull information there. 在没有Visual Studio情况下运行该应用程序,请等到失败为止,然后转到Event Viewer以在其中查找一些有用的信息。

  4. Get Process Monitor , run the application without Visual Studio , wait until it fails, stop monitoring and filter the list by the application name and failed operations and look there for some usefull information. 获取Process Monitor ,在没有Visual Studio情况下运行应用程序,等到失败为止,停止监视并按应用程序名称和失败的操作筛选列表,然后在其中查找一些有用的信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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