You’re hitting a System.MethodAccessException from .NET’s Code Access Security (CAS) when your tool starts, specifically involving Microsoft.StylusInput and Microsoft.Ink. This kind of error usually happens when a security-transparent method tries to call a native or unsafe method, and .NET’s security model blocks it. The tricky part is that your project has been working fine for 8 years, but likely a recent .NET Framework update or Windows update tightened the security rules for CAS.
Here’s the situation in human terms: the framework is saying, “Hey, this old method wants to do something unsafe, and I can’t just let it go without marking it properly.” But you don’t want to resurrect or heavily modify the old code.
Practical ways to handle this without rewriting everything:
Target an older .NET Framework version (if possible)
Many of these CAS restrictions were relaxed in older versions.
If your tool currently runs on, say, **.NET 4.8**, you might try **running it on 4.6 or 4.5**, if feasible.
**Use the `LegacyCasPolicy` setting**
In your app.config, add:
```
<configuration>
<runtime> <NetFx40_LegacySecurityPolicy enabled="true"/> </runtime> </configuration> ```
This can allow the old CAS behavior without touching the code.
**Run the app as full trust**
If this is a desktop app, make sure it’s **not running in partial trust** or via a network share. Full-trust execution usually bypasses this exception.
**Shim the problem with a small wrapper**
If you really want a minimal intervention, you can create a **small helper assembly** marked as **security-critical** that calls the native methods and leaves the rest of your old code untouched.
TL;DR (developer-to-developer version): Your old code worked fine until .NET tightened security rules. The easiest fixes are either enable legacy CAS policy in your config, run the app fully trusted, or target an older .NET Framework. That way, you can avoid touching the decades-old code and still get the tool running.
If you want, I can write a ready-to-use app.config snippet that will likely fix this immediately without any code changes.