0

My C# rdp client use AxInterop.MSTSCLib ActiveX in a Form. I want to package mstscax.dll together with my application. Microsoft has dll redirection and side-by-side tech to resolve dll hell problem. I have tried dll redirection by creating a RDPClient.exe.local file but no effect. I have found some examples of manifest but they're all used in c++ projects. How to create a manifest in C# vs2019 project to limit the mstscax.dll search path of AxInterop.MSTSCLib?

StayOnTarget
  • 11,743
  • 10
  • 52
  • 81
Acewind
  • 133
  • 9
  • 1
    I've only done this for VB6 executables, not C#. Have you googled / read articles like the following? https://weblog.west-wind.com/posts/2011/oct/09/an-easy-way-to-create-side-by-side-registrationless-com-manifests-with-visual-studio – StayOnTarget Aug 25 '20 at 12:06
  • @UuDdLrLrSs According to the article, I set isolated=true on AxMSTSCLib&MSTSCLib, then vs2019 generates a manifest file and copy mstsxax.dll to my bin/x64/Debug output directory. When I run my exe in debug mode by vs2019, a System.BadImageFormatException occurs and the StackTrace shows exception is at System.Windows.Forms.UnsafeNativeMethods.CoCreateInstance(Guid& clsid, Object punkOuter, Int32 context, Guid& iid) – Acewind Aug 25 '20 at 12:51
  • I check the file mstscax.dll in output directory, it has a deferent size and detail info to C:\Windows\System32\mstscax.dll. Where is it from? I try copy C:\Windows\System32\mstscax.dll to output directory and run my exe again, the same exception occurs. – Acewind Aug 25 '20 at 13:04
  • You may have more than one copy of that DLL on the PC, and the one in system32 is not the one that was registered. Easiest thing is probably to do a filesystem search. Then unregister all copies, and finally register just the correct one. (Using regsvr32, probably) – StayOnTarget Aug 25 '20 at 13:06
  • I run with Debug/Any CPU, not Debug/x64, in vs2019, it loads mstscax.dll in output directory successfully. Maybe arch of dll is required to be set somewhere? – Acewind Aug 25 '20 at 13:11
  • Is it a 64 bit DLL? – StayOnTarget Aug 25 '20 at 13:12
  • When I run with Debug/x64 settings, it copies original mstscax.dll from C:\Windows\SysWOW64 to my output directory. – Acewind Aug 25 '20 at 13:18
  • When I copy C:\Windows\System32\mstscax.dll to output directory and run with Debug/x64 mode, it says BadImageFormatException. When I run run with Debug/Any CPU mode, it loads dll but failed to find MUI. I try copy mui from C:\Windows\SysWOW64 to output directory and zh-CN sub directory, it still complains. – Acewind Aug 25 '20 at 13:21
  • SysWOW64 contains 32-bit DLLs, and System32 has the 64-bit ones. (Yes, it seems backwards, but this is correct). Of course you might have had the wrong DLL in the wrong place. As for the MUI... I don't know what that is. – StayOnTarget Aug 25 '20 at 13:51
  • My mistake ... I copy 32-bit DLL to x64 output directory. May I disable auto copy action of vs2019? – Acewind Aug 25 '20 at 13:56
  • 1
    If you rely on the manifest, I think you must copy the DLL to the output dir, AFAIK – StayOnTarget Aug 25 '20 at 14:24

0 Answers0