-
Notifications
You must be signed in to change notification settings - Fork 94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ShellLink
missing ComImport
attribute
#453
Labels
bug
Something isn't working
Comments
Discussed here as well: #323 |
Thanks! Glad to hear i'm not alone. I always forget to check Discussions as well. |
I was able to get your code running with just one change: -ShellLink shellLink = new ShellLink();
+object shellLink = Activator.CreateInstance(Type.GetTypeFromCLSID(typeof(ShellLink).GUID)); |
I'll fix this by generating |
AArnott
added a commit
that referenced
this issue
Nov 23, 2021
craigktreasure
added a commit
to craigktreasure/StartMenuCleaner
that referenced
this issue
Mar 11, 2022
- In CsWin32 0.1.635-beta, the ShellLink class became cocreatable, which allows me to restore my original method of creating a `ShellLink`. See microsoft/CsWin32#453.
craigktreasure
added a commit
to craigktreasure/StartMenuCleaner
that referenced
this issue
Mar 11, 2022
- In CsWin32 0.1.635-beta, the ShellLink class became cocreatable, which allows me to restore my original method of creating a `ShellLink`. See microsoft/CsWin32#453.
craigktreasure
added a commit
to craigktreasure/StartMenuCleaner
that referenced
this issue
Mar 11, 2022
* Update System.IO.Abstractions to 16.1.20 * Update CsWin32 to 0.1.635-beta * Use newly cocreatable `ShellLink` from updated CsWin32 - In CsWin32 0.1.635-beta, the `ShellLink` class became cocreatable, which allows me to restore my original method of creating a `ShellLink`. See microsoft/CsWin32#453.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
In full disclosure, I'm a COM newb. Feel free to slap me and tell me i'm doing it completely wrong.
I'm using CsWin32 to read the target of an
.lnk
file. Some searching lead me to this solution, which does work for me. I thought I'd supplement the hand-written bits with types generated from CsWin32. Everything works except the definition ofShellLink
, which appears to be astruct
instead of aclass
and lacking the necessaryComImport
attributes to allow you to cast it to anIPersistFile
and anIShellLInkW
.Actual behavior
The generated code for
Windows.Win32.ShellLink.g.cs
:Expected behavior
Again, I'm bashing rocks together from StackOverflow, but the signature there includes a
ComImport
attribute that I believe is necessary and the type is also aclass
instead of astruct
. If I omitShellLink
fromNativeMethods.txt
and use this definition instead, things do work.Repro steps
NativeMethods.txt
content:NativeMethods.json
content (if present):Not present.
Attempt to resolve the target of a
.lnk
:Context
LangVersion
(if explicitly set by project): 10.0The text was updated successfully, but these errors were encountered: