微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

System.Type.GetTypeFromProgID(VisualStudioProgId) 返回 null

如何解决System.Type.GetTypeFromProgID(VisualStudioProgId) 返回 null

请帮帮我:

机器 1:win2007(工作正常)
机器 2:winServer 2019 Datacenter(面临问题)
在两台机器上:在 VS2019 上执行相同的 C# 代码,我想调用 VS2017

C# 代码

string VisualStudioProgId = "VisualStudio.DTE." + vsversion;
Type type = System.Type.GetTypeFromProgID(VisualStudioProgId);
EnvDTE80.DTE2 dte = (EnvDTE80.DTE2)System.Activator.CreateInstance(type,true);
  1. 代码在机器 1(win2007) 上运行良好
  2. 在机器 2(winServer 2019) 上 - 报告了未处理的异常:

    enter image description here

我尝试在两台机器的 VS2019 中进一步调试 C# 代码
观察到 type 的不同 Class System Type

机器(win2007)(工作正常):
Class System Type 观察为
Value: {Name = "__ComObject" FullName = "System.__ComObject"}
Type: System.Type {System.RuntimeType}

enter image description here

机器(winServer 2019)(面临问题):
Class System Type 观察为
Value: null
Type: System.Type

enter image description here

解决方法

在查看正在运行的 machine(win2007) 中的 VS 安装后,我安装了更多软件包。
现在 machine with winServer 2019 也在工作。但我现在不知道哪个包解决了这个问题。

之前的包: enter image description here

安装了更多软件包

Microsoft Visual Studio Community 2017 
Version 15.9.36
VisualStudio.15.Release/15.9.36+28307.1525
Microsoft .NET Framework
Version 4.8.03761

Installed Version: Community

ASP.NET and Web Tools 2017   15.9.04012.0
ASP.NET and Web Tools 2017

ASP.NET Core Razor Language Services   15.8.31590
Provides languages services for ASP.NET Core Razor.

ASP.NET Web Frameworks and Tools 2017   5.2.61435.0
For additional information,visit https://www.asp.net/

Azure App Service Tools v3.0.0   15.9.03024.0
Azure App Service Tools v3.0.0

C# Tools   2.10.0-beta2-63501-03+b9fb1610c87cccc8ceb74a770dba261a58e39c4a
C# components used in the IDE. Depending on your project type and settings,a different version of the compiler may be used.

Common Azure Tools   1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

JavaScript Language Service   2.0
JavaScript Language Service

Microsoft Continuous Delivery Tools for Visual Studio   0.4
Simplifying the configuration of Azure DevOps pipelines from within the Visual Studio IDE.

Microsoft JVM Debugger   1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

Microsoft Library Manager   1.0
Install client-side libraries easily to any web project

Microsoft MI-Based Debugger   1.0
Provides support for connecting Visual Studio to MI compatible debuggers

Microsoft Visual Studio Tools for Containers   1.1
Develop,run,validate your ASP.NET Core applications in the target environment. F5 your application directly into a container with debugging,or CTRL + F5 to edit & refresh your app without having to rebuild the container.

NuGet Package Manager   4.6.0
NuGet Package Manager in Visual Studio. For more information about NuGet,visit http://docs.nuget.org/.

ProjectServicesPackage Extension   1.0
ProjectServicesPackage Visual Studio Extension Detailed Info

ResourcePackage Extension   1.0
ResourcePackage Visual Studio Extension Detailed Info

ResourcePackage Extension   1.0
ResourcePackage Visual Studio Extension Detailed Info

SQL Server Data Tools   15.1.62002.01090
Microsoft SQL Server Data Tools

TcProjectCompare   1.0
Visual Studio Integrated Version of TcProjectCompare

TcXaeDebuggerLiveWatch   1.0
TwinCAT XAE Live Watch Tool Window

TcXaeHelper   1.0
Info

TcXaeModules   1.0
TwinCAT TMC Editor,TwinCAT TMC Code Generator

TcXaeStartPage   1.12
Beckhoff Start Page for TwinCAT XAE

TwinCAT XAE Base   3.1.0.0
The TwinCAT XAE Base extension provides the basic project structure for TwinCAT projects.

TwinCAT XAE EventLogger   1.0
The TwinCAT XAE Eventlogger extension provides the capability of monitoring events sent through the TwinCAT 3 Eventlogger of a target system.

TwinCAT XAE PLC   3.1.0.0
PLC Environment

TypeScript Tools   15.9.30718.2001
TypeScript Tools for Microsoft Visual Studio

Visual Basic Tools   2.10.0-beta2-63501-03+b9fb1610c87cccc8ceb74a770dba261a58e39c4a
Visual Basic components used in the IDE. Depending on your project type and settings,a different version of the compiler may be used.

Visual Studio Code Debug Adapter Host Package   1.0
Interop layer for hosting Visual Studio Code debug adapters in Visual Studio

Visual Studio Tools for Containers   1.0
Visual Studio Tools for Containers

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?