Search code examples
c#comvisible

C# ComVisible DLL only usable by IIS when Remote Desktop connected


I've created a ComVisible DLL which is signed with a given domain name (the company I work for). I place this DLL onto a customer's web host machine, which runs under a different domain, and register it using: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\regsvcs

The DLL creates a XLSX file on a disk local to the customer's web host. The user can download this file with a browser.

If I have a remote desktop session open to the customer's web host, the DLL acts as expected and the customer can download the temporary file which is created.

However, as soon as I drop the remote desktop session (I don't log out and I leave the VPN connected), the DLL is no longer accessible. The temporary file is no longer created by the asp classic site, and the customer of course is unable to stream the file which isn't created.

Any thoughts on what can cause this? The web server generates no errors.

I figured the DLL being signed with a different domain name then the web server hosts is part of the problem, but can't imagine why having a Remote Desktop session open (I just use mstsc by Microsoft) fixes the issue.


Solution

  • In the end I removed the following code from AssemblyInfo.cs:

    [assembly: ComVisible(true)]
    [assembly: ApplicationActivation(ActivationOption.Server)]
    [assembly: ApplicationAccessControl(false,
        AccessChecksLevel = AccessChecksLevelOption.ApplicationComponent)]
    

    I moved ComVisible and my Guid call to be a decorator on the class I want to expose to COM, and now the DLL always instantiates correctly and works without error.

    I also now register using:

    RegAsm.exe d:\foo\bar.dll /codebase /tlb