0

I have a simple "login" screen in C# where the user will press Login and another window pops up saying welcome and is working when I build/run on Visual Studio.

Here is the code

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Login_Test
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            MessageBox.Show("Welcome");
            this.Close();
        }
    }
}

I also have a VBA form (Access 2010) where a user will click a button, then the C# form should pop up and in the future, instead of saying "welcome" it will redirect to a different form in Access.

Here is the code for the VBA button:

Private Sub Command284_Click()
    Dim objLog As Login_Test.Form1
    Set objLog = New Login_Test.Form1
End Sub

I have made the .dll, .tlb, used regasm on it, and referenced it on Access.

I get: "runtime error 429 activex component can't create object" when pressing the button.

Am I missing something?

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
Nate
  • 87
  • 10
  • is it `ComVisible`? – cyboashu Jul 20 '16 at 16:34
  • @cyboashu where would I put that line ( [ComVisibleAttribute(true)] )? – Nate Jul 20 '16 at 16:39
  • before dll's entry point (the main/root class of dll) see this : http://stackoverflow.com/questions/7092553/turn-a-simple-c-sharp-dll-into-a-com-interop-component – cyboashu Jul 20 '16 at 16:42
  • @cyboashu , yes i have "Make assembly COM-Visible" enabled – Nate Jul 20 '16 at 17:57
  • what is the regasm syntax that you are using to register? – cyboashu Jul 20 '16 at 17:58
  • @cyboashu I did that part yesterday, but if I remember correctly it was: " "regasm.exe Login_Test.dll /tlb:Login_Test.tlb" I copied the dll and tlb to Syswow64 folder. Then it says ...something successful. I used tutorial: http://www.geeksengine.com/article/register-dll.html – Nate Jul 20 '16 at 18:14
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/117842/discussion-between-cyboashu-and-nate). – cyboashu Jul 20 '16 at 18:31

1 Answers1

1

Launch developer command prompt in Admin mode, run this synatx:

regasm.exe Login_Test.dll /tlb /CodeBase

You can keep Login_test.dll anywhere, just provide the full path in command.

cyboashu
  • 10,196
  • 2
  • 27
  • 46