none
Class Library Won't Run RRS feed

  • Question

  • I created a C# Windows Class Library project with this class:

    namespace TestDLL
    {
        public class TestClass
        {
            public int TestDouble(int iInput)
            {
                int iDouble = iInput * 2;
                return iDouble;
            }
        }
    }

    I built the class library probject successfully.  I created this VB script file to test the class:

    Dim iReturn
    Dim oTest
    
    MsgBox "Start Test Double"
    
    Set oTest = CreateObject("TestDLL.TestClass")
    
    MsgBox "CreateObject Complete"
    
    iReturn = oTest.TestDouble(2)
    
    Set oTest = Nothing
    
    MsgBox "End Test Double"

    When I try to run the test script it fails on the CreateObject line with the error "Specified module could not be found".  I'm running the test script on the same machine.  Do I have to create a setup project and deploy the class library to the same machine in order for the script to run?


    MCSD .NET developer in Dallas, Texas


    • Edited by DallasSteve Wednesday, September 26, 2012 8:26 PM
    Wednesday, September 26, 2012 8:25 PM

Answers

  • I solved my problem.  A .NET Class Library by default is not visible to COM.  So to call CreateObject from VBScript you must

    1 - Check Register For COM Interop under the project's Build property.

    2 - Change false to true for the line [assembly: ComVisible(true)] in AssemblyInfo.cs file.


    MCSD .NET developer in Dallas, Texas

    • Marked as answer by DallasSteve Wednesday, September 26, 2012 9:22 PM
    Wednesday, September 26, 2012 8:54 PM

All replies

  • I solved my problem.  A .NET Class Library by default is not visible to COM.  So to call CreateObject from VBScript you must

    1 - Check Register For COM Interop under the project's Build property.

    2 - Change false to true for the line [assembly: ComVisible(true)] in AssemblyInfo.cs file.


    MCSD .NET developer in Dallas, Texas

    • Marked as answer by DallasSteve Wednesday, September 26, 2012 9:22 PM
    Wednesday, September 26, 2012 8:54 PM
  • Glad to hear you have solved your error.

    If you want to ask related questions, I recommend you post it here:

    http://social.msdn.microsoft.com/Forums/en/clr/threads

    Regards,


    Barry Wang [MSFT]
    MSDN Community Support | Feedback to us

    Thursday, September 27, 2012 7:42 AM
    Moderator