J
J
jammywork12015-06-09 11:18:13
Windows
jammywork1, 2015-06-09 11:18:13

Why can't I use an assembly registered in the system?

I wrote a library in c#, I want to use it in MS Access using COM tools.
The essence of the problem is that if I register my assembly in the system using Visual Studio, I can use it in MS Access by simply pointing reference to it, and then refer to it using VBA. But if I do it manually using regasm or tlbexp, then when I try to call any classes from the assembly, I get an error in RunTime: The specified file cannot be found.
d99a709e43314be98bf620b0ae19c08c.pngc6dcd979a3d2476e81f7bede77ec756e.png
Registration options:
e0ab5cb3f1b6462b8b53269dd7db393c.png
However, by checking the checkbox to register the assembly through VS, I can use the assembly without any problems.
edd50bcbb2a747aba0f3a92173904b9c.pngb307429e910a4290a5b32b0992b5cb19.png
Example source code

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;

namespace ClassLibrary1
{
    [ComVisible(true)]
    public class Class1
    {
        public string getTest()
        {
            return "Test Success";
        }
    }
}

VBA
Option Compare Database

Private Sub Button0_Click()

Dim test As TestBuild.Class1
Set test = New TestBuild.Class1
Debug.Print test.getTest

End Sub

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vitaly Pukhov, 2015-06-09
@Neuroware

Purely theoretically, because there is nowhere to check now. Office 64 bit? If yes, then the assembly must also be 64 bit and register via "%Windir%\Microsoft.NET\Framework64\v2.0.50727\regasm" "$(TargetPath)" for version 2 net

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question