dlech / KeeAgent

ssh agent plugin for KeePass 2.x
http://lechnology.com/software/keeagent
Other
522 stars 35 forks source link

"The plugin cannot be loaded A newer .NET framework is required." error on Linux #343

Closed dlech closed 1 year ago

dlech commented 2 years ago

.... However there is another problem using KeeAgent on mono.

image

As root create the path mkdir -p "/etc/mono/registry/LocalMachine/software/microsoft/net framework setup/ndp/v4/full/"

Inside this path create a file named "values.xml" echo -e "<values>\n<value name="Install" type="string">1</value>\n<value name="Version" type="string">4.8.04084</value>\n</values>\n" > "/etc/mono/registry/LocalMachine/software/microsoft/net framework setup/ndp/v4/full/values.xml"

Content of values.xml

<values>
<value name="Install" type="string">1</value>
<value name="Version" type="string">4.8.04084</value>
</values>

When I do the registry patch KeeAgent is running...

Originally posted by @jnko in https://github.com/dlech/KeeAgent/issues/341#issuecomment-1120640785

dlech commented 2 years ago

For technical reasons, we have had to bump the minimum .NET version to 4.6.2. For some reason, even though Mono is compatible with this version, it still reports an older version. As mentioned in the previous comment, there is a workaround. At a minimum, we need to document this, but it would be even better if we could find solution that doesn't require users to have to research the error and find the workaround.

jnko commented 2 years ago

Thanks for clarifying.

I can confirm that for running with mono we still need to set some registry values either globally or in user context. According to https://docs.microsoft.com/en-us/dotnet/framework/migration-guide/how-to-determine-which-versions-are-installed the registry value of the Release key must be set to 394802 for .NET 4.6.2.

The globally method (Execute as root):

mkdir -p /etc/mono/registry/LocalMachine/software/microsoft/net\ framework\ setup/ndp/v4/full
echo -e '<values>\n<value name="Install" type="string">1</value>\n<value name="Version" type="string">4.6.2</value>\n<value name="Release" type="int">394802</value>\n</values>\n' > "/etc/mono/registry/LocalMachine/software/microsoft/net framework setup/ndp/v4/full/values.xml"
chmod -R ugo+r /etc/mono/registry

The User-Context method (Execute as User): The "trick" is to change the environment variable MONO_REGISTRY_PATH to mono, either in your user environment or by prefixing it.

mkdir -p ~/.mono/registry/LocalMachine/software/microsoft/net\ framework\ setup/ndp/v4/full/
echo -e '<values>\n<value name="Install" type="string">1</value>\n<value name="Version" type="string">4.6.2</value>\n<value name="Release" type="int">394802</value>\n</values>\n' > ~/.mono/registry/LocalMachine/software/microsoft/net\ framework\ setup/ndp/v4/full/values.xml
MONO_REGISTRY_PATH=~/.mono/registry mono KeePass.exe database.kdbx

The values.xml-File for both methods should look like:

<values>
<value name="Install" type="string">1</value>
<value name="Version" type="string">4.6.2</value>
<value name="Release" type="int">394802</value>
</values>

A bit tricky but fortunately KeePass and KeeAgent will perfectly run with mono now. Use KeeAgent version (or higher) mentioned at

System.DllNotFoundException: Comctl32.dll assembly:<unknown assembly> type:<unknown type> member:(null)

@jnko, this should be fixed now: https://github.com/dlech/KeeAgent/suites/6440404711/artifacts/235755018

dlech commented 2 years ago

I have submitted a patch to KeePass to fix this so we don't have to mess with fake windows registry: https://sourceforge.net/p/keepass/patches/130/

dlech commented 2 years ago

The upstream patch was accepted (use the link above to get build of KeePass 2.x for testing). So now this will just be a matter of documenting that KeePass 2.52 is the minimum required version on Linux.