We are trying to write some applications. One ASP.NET site uses the .NET Assembly xxx.Elements.dll, which provides utility functions.
Another classic ASP site must also use the same DLL to use the same utility functions. (It will be used to encrypt data between two sites).
Despite numerous attempts by Google, we cannot get this to work.
We have:
Apply ComVisibility to Assembly.info and make sure there is a guide:
[assembly: ComVisible(true)] [assembly: Guid("ab96fbc3-aa39-4fb6-8628-13778445e503")]
We made sure that our type captures the fields on type visibility, ensuring that it has a default constructor, is ComVisible, and has a Guid. We also created a simplified testing method:
namespace xxx.Elements { [GuidAttribute("D3BE2C7D-7550-4da1-8F61-6871E193242F")] [ComVisible(true)] public class UrlUtility : IUrlUtility { public UrlUtility() { } public string Test() { return "HellO"; } } }
Using the interface:
[GuidAttribute("D3BE2C7D-7550-4da1-8F61-6871E193242A")] [ComVisible(true)] public interface IUrlUtility { string Test(); }
We found this useful (albeit non-permissive) entry here for this: warning MSB3391: does not contain types that may be unregistered for COM Interop.
We also checked Regsiter for COM-Interop on the project properties pages.
This continues to issue a warning:
c:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(3341,9): warning MSB3214: "D:\dev\yyy\xxx.Elements\bin\Release\xxx.Elements.dll" does not contain any types that can be registered for COM Interop.
when compiling. If we run REGASM xxx.Elements.dll /tlb directly, we get:
Microsoft (R) .NET Framework Assembly Registration Utility 4.0.30319.1 Copyright (C) Microsoft Corporation 1998-2004. All rights reserved. Registered Types The assembly is exported to 'D: \ dev \ yyy \ IWW.Elements \ bin \ release \ xxx.eleme nts.tlb' and the type library was successfully registered
So a little confused in the ambiguity.
When we look in the registry, it seems to register .tlb correctly:
Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\TypeLib\{AB96FBC3-AA39-4FB6-8628-13778445E503}] [HKEY_CLASSES_ROOT\TypeLib\{AB96FBC3-AA39-4FB6-8628-13778445E503}\1.1] @="Elementary support library for xxx' products" [HKEY_CLASSES_ROOT\TypeLib\{AB96FBC3-AA39-4FB6-8628-13778445E503}\1.1\0] [HKEY_CLASSES_ROOT\TypeLib\{AB96FBC3-AA39-4FB6-8628-13778445E503}\1.1\0\win32] @="D:\\dev\\yyy\\xxx.Elements\\bin\\Release\\xxx.Elements.tlb" [HKEY_CLASSES_ROOT\TypeLib\{AB96FBC3-AA39-4FB6-8628-13778445E503}\1.1\FLAGS] @="0" [HKEY_CLASSES_ROOT\TypeLib\{AB96FBC3-AA39-4FB6-8628-13778445E503}\1.1\HELPDIR] @="D:\\dev\\yyy\\xxx.Elements\\bin\\Release"
We also registered type in GAC:
gacutil /i xxx.Elements.dll
and gave him a strong name using:
sn -k xxx.Elements.snk
and included the name in the AssemblyInfo.cs file:
[assembly: AssemblyKeyFile(@"D:\dev\yyy\xxx.Elements\xxx.Elements.key")]
We also applied the IUSR user. Allow reading registry keys:
HKEY_CLASSES_ROOT\TypeLib\{AB96FBC3-AA39-4FB6-8628-13778445E503} HKEY_USERS\S-1-5-20\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones
(the latter was suggested here: Unable to initiate .Net COM object on classic ASP / VBScript page (ASP error 0177) )
Despite all this, when we activate an object on an ASP page using code:
dim urlUtility set urlUtility = Server.CreateObject("xxx.Elements.UrlUtility") ' should return "Hello" test=urlUtility.Test()
The process stops, and when we debug the W3WP process, we get an error:
Server Object: 006 ~ ASP 0177 ~ .CreateObject Server Failure ~ 800401f3
We tried to check all the checkboxes, but we have to miss something. Any ideas please?