4

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.

Developer Webs
  • 983
  • 9
  • 29

2 Answers2

1

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
Developer Webs
  • 983
  • 9
  • 29
0

If you are working with XLSX files and getting this behavior I am fairly confident you are using the Office.Interop classes to do it. Using those interop COM classes are not supported from inside IIS. If you do try to use it from inside IIS you get the behavior exactly like you are describing.

You must switch to a different library like the Open XML SDK for Office to create the XLSX files instead.

The reason behind why it works once you RDP in is the interop dll's need a desktop session to function correctly. While you are RDPed in there is a session for it to use, once you disconnect there is no-longer a session for it.

Scott Chamberlain
  • 124,994
  • 33
  • 282
  • 431
  • I'm using DocumentFormat.OpenXml. However, in my AssemblyInfo.cs I had the following: `[assembly: ComVisible(true)] [assembly: ApplicationActivation(ActivationOption.Server)] [assembly: ApplicationAccessControl(false, AccessChecksLevel = AccessChecksLevelOption.ApplicationComponent)]` I suspect one or both of these lines are culprit? The MSDN doesn't document them well enough for my liking. I've since removed both of these lines, and moved ComVisible and Guid to be a decorator onto the one class I want to expose, and it now works correctly. – Developer Webs Apr 21 '16 at 15:08
  • I would recommend you post an answer to your own question with those details and accept it. – Scott Chamberlain Apr 21 '16 at 15:13