c# - 错误 CS0117:“元帅”不包含“GetTypeFromCLSID”的定义
问题描述
我在 .NET 中创建了一个项目,并在 Visual Studio 2017 中不断出现错误,就像上面的标题一样。
我一直在寻找不同的解决方案,但没有任何效果,所以我决定在这里问我的问题,也许你能帮助我。
代码:
namespace MSBuilderTx
{
using IWshRuntimeLibrary;
using Microsoft.Win32;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Management;
using System.Net;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Security.AccessControl;
using System.Security.Principal;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Timers;
using System.Windows.Forms;
internal class Program
{
private const int MAXTITLE = 0xff;
private static ArrayList mTitlesList;
private static Regex rgx = new Regex("[^a-zA-Z0-9 -]");
private const int SW_HIDE = 0;
private const int SW_SHOW = 5;
[DllImport("user32.dll", EntryPoint="EnumDesktopWindows",
CharSet=CharSet.Auto, SetLastError=true)]
private static extern bool _EnumDesktopWindows(IntPtr
hDesktop, EnumDelegate lpEnumCallbackFunction, IntPtr lParam);
[DllImport("user32.dll", EntryPoint="GetWindowText",
CharSet=CharSet.Auto, SetLastError=true)]
private static extern int _GetWindowText(IntPtr hWnd,
StringBuilder lpWindowText, int nMaxCount);
public static void CreateShortcut(string shortcutName, string
shortcutPath, string targetFileLocation)
{
string pathLink = Path.Combine(shortcutPath, shortcutName
+ ".lnk");
WshShell shell = (WshShell)
Activator.CreateInstance(Marshal.GetTypeFromCLSID(new
Guid("72C24DD5-D70A-438B-8A42-98424B88AFB8")));
IWshShortcut shortcut = (IWshShortcut)
shell.CreateShortcut(pathLink);
shortcut.Description = "Pixie Shortcut";
shortcut.TargetPath = targetFileLocation;
shortcut.Save();
}
线
WshShell shell = (WshShell)
Activator.CreateInstance(Marshal.GetTypeFromCLSID(new Guid("72C24DD5-
D70A-438B-8A42-98424B88AFB8")));
给出错误信息。
解决方案
推荐阅读
- javascript - chart.js:连接两个折线图的问题
- .htaccess - 如何强制将 http 和 www 重定向到 https
- javascript - 带有 CDN 的 Vue - 设置组件样式的最佳方式
- windows - 我们可以在复制过程中打开 Robocopy 日志吗?
- python - Floyd-Warshall 到 Graph networkx
- ios - 如何检查 nil 是否已经强制向下转换的属性
- r - 为什么向量没有用新值更新
- teradata - 自动提交 Teradata SQL 助手
- android - 没有为多个单词设置可点击跨度
- c# - 基准点网。是否可以包括未预热的结果?