开发者

.NET app.config file containing useLegacyV2RuntimeActivationPolicy not being used when app launched via file association

My app needs useLegacyV2RuntimeActivationPolicy in its .exe.config because it is a CLR4 app that uses mixed mode CLR2 assemblies.

All is well when starting our app from the Start Menu, but if a user starts our a开发者_JAVA百科pp by clicking on one of their files that has a file type association with our app, the app.config file is not being read and the loading of these CLR2 assemblies fails.

Based on further research, it appears that ShellExecute does not read the .config file (even when the app folder is specified), but WinExec does. I presume the shell uses ShellExecute for starting an app via file association.

Is there any workaround for this besides writing an intermediate app that sets the current folder before starting the main app's process? This was suggested elsewhere on this site.

Thanks in advance!


Check that the file association registry settings use long filenames and not short filenames. For example, the command value here should use the long filename to open the document.

HKEY_CLASSES_ROOT\MyFile.Document\shell\open\command

My guess is that Windows does not expand the short filename into the long name when starting the application and tries to use the short name to resolve the app.config file which it then fails to find.

Edit: I confirmed my theory by renaming the app.config with the matching short name found in the registry and then it worked. Removing the renamed app.config file again breaks it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜