COM cannot start out-of-process .Net server compiled as AnyCPU

前端 未结 2 1087
青春惊慌失措
青春惊慌失措 2021-02-04 14:24

I am trying to get COM to start my out-of-process .NET COM server. It works if the server process is compiled with x64, but if I use AnyCPU (which is what I want) then it hangs

2条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-04 15:12

    Try to use the RegistrationServices class to register your com assembly. It will also choose the correct registry pathes and do some other things.

    Example:

    Assembly currentAssembly = Assembly.GetExecutingAssembly();
    System.Runtime.InteropServices.RegistrationServices regAsm = new System.Runtime.InteropServices.RegistrationServices();
    bool isRegistered = regAsm.RegisterAssembly(currentAssembly, System.Runtime.InteropServices.AssemblyRegistrationFlags.SetCodeBase);
    

    Also I think, that .NET client assemblies have some trouble according to .NET com servers, but I can't find any resource for it...

    Hope, it will help...

提交回复
热议问题