4

I am writing a application using ASP and VBScript. There a library I can only find one written for .Net application. So I tried to create a class library wrapper and compiled it to a DLL using VB.Net (Microsoft Visual Basic 2010 Express).

The DLL works in my own desktop (Windows 7) but it fails in the server (Server 2000).

Error message is "System cannot find the file specified"

Server config

OS: Microsoft Windows 2000 Server (SP4)

.Net framework installed: v2.0.50727

The code I wrote in my testing project is simply a class doing nothing.

Imports System.IO
Imports System

<ComClass(Object1.ClassId, Object1.InterfaceId, Object1.EventsId)> _
Public Class Object1
#Region "COM GUIDs"
    ' These  GUIDs provide the COM identity for this class 
    ' and its COM interfaces. If you change them, existing 
    ' clients will no longer be able to access the class.
    Public Const ClassId As String = "f5dcfb08-7a83-4501-bd89-03e38cad819c"
    Public Const InterfaceId As String = "8a313e0b-60e5-4ff4-8a7d-e7b1582eec71"
    Public Const EventsId As String = "fe55f7d8-691f-4c76-968a-37019fa9bb53"
#End Region

    ' A creatable COM class must have a Public Sub New() 
    ' with no parameters, otherwise, the class will not be 
    ' registered in the COM registry and cannot be created 
    ' via CreateObject.
    Public Sub New()
        MyBase.New()
    End Sub

    Public Sub Hello()
        '...
    End Sub
End Class

What I did :

  • Chose ".NET Framework 2.0" in Compile options

  • Compile it on my own desktop

  • Copied all file from the Bin\Release directly to a folder on the server.

  • Successfully registered the DLL on the server using Regasm.exe

but Object1 cannot be created using neither VB6 or VBScript.

Here is the script I used in a VBScript:

Option Explicit

Dim TestObject
Set TestObject = CreateObject("TestComObject.Object1")

Any help will be appreciated!

Alex

1
  • Download DependencyWalker on the server and run it over your wrapper DLL. It's entirely possible one of the dependencies can't be resolved. Unfortunately Windows is terrible at giving you specific details as to what's missing, as you've found. Commented Aug 23, 2013 at 4:07

1 Answer 1

2

Go through the following check-list:

1) Make sure you compile your assembly as 32-bit (in the VB.NET project settings)

2) Give your assembly a strong name (http://msdn.microsoft.com/en-us/library/xc31ft41.aspx). You can probably configure this in your VB.NET project settings as well.

3) Use RegAsm for .NET 2.0 (C:\Windows\Microsoft.NET\Framework\v2.0.50727\RegAsm.exe)

4) Call RegAsm with "/codebase" switch

5) Before testing with ASP, try running your test script from command line with WScript.exe.

Sign up to request clarification or add additional context in comments.

3 Comments

Thank you! Point 4) exactly resolves the problem I've encountered. I have tried to go without point 2) and it looks working fine too.
You're welcome! I'll make a note for myself that strong name is not required.
I was doing everything in your steps and found that if you're on a 64bit os then you'll need the 64b version of regasm: C:\Windows\Microsoft.NET\Framework64\v2.0.50727\regasm.exe

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.