G
Gary
I'm using an Act database. I was stuck on this a year ago and am still
having trouble.
I have three bits of code like so : -
act.CActAppObj objACT = new act.CActAppObj();
act.CAIBaseView objBaseView = new act.CAIBaseView();
act.CAIViews objViewsCollection = new act.CAIViews();
The first part compiles fine. The second and third. Both generate
errors like so: -
System.Runtime.InteropServices.COMException was unhandled
Message="Retrieving the COM class factory for component with CLSID
{0CD44B28-F861-11D0-9B45-006097B00E23} failed due to the following
error: 80040154."
Source="WindowsApplication1"
ErrorCode=-2147221164
StackTrace:
at WindowsApplication1.Form1.Form1_Load(Object sender, EventArgs
e)
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
at System.Windows.Forms.Control.set_Visible(Boolean value)
at
System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32
reason, ApplicationContext context)
at
System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32
reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at WindowsApplication1.Program.Main()
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[]
args)
at System.AppDomain.ExecuteAssembly(String assemblyFile,
Evidence assemblySecurity, String[] args)
at
Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object
state)
at System.Threading.ExecutionContext.Run(ExecutionContext
executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
Am i right in thinking because the first statement compiles OK the
problem isn't to do with the DLL being registered? Sometime ago when I
last looked at this I seem to remember trying to use a utility called
tlbimp to fix it but didn't get very far.
Someone gave me some code sometime ago which is what my code is based
on.
They said that the code would work for VB6.
I am trying to get it working in .net C# here is some of their code
that i'm basing my code on.
=========================================================
Me.ActEvent1.Register 0 'ACT! must be open. This registers this program
with ACT!
'check and see if ACT! is running
If Me.ActEvent1.IsActRunning <> True Then
MsgBox "Open ACT! and start again.", vbCritical, "ACT! is closed"
End
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
'Unregister with ACT! when our program unloads.
Me.ActEvent1.UnRegister
End Sub
'ACT! informs you of this event when a user adds a new Contact
'from the Contact View or Contact List View in ACT!
Private Sub ActEvent1_OnContactAdd(ByVal lpszUniqueID As String)
Dim objACT As New act.CActAppObj 'The ACT application object
Dim objViewsCollection As act.CAIViews 'The collection of all views in
ACT!
Dim objBaseView As act.CAIBaseView 'A generic "base view" in ACT! We
need this to determine
'if the new Contact is being added from the Contact view/screen
'or the Contact List view/screen.
Set objViewsCollection = objACT.Views 'Get all view from ACT!
Set objBaseView = objViewsCollection.GetActive 'Get the active
view/screen from the collection
'This logic determines which view/screen the user is using when adding
the new Contact.
'NOTE: the "Active" view is the currently visible view/screen the user
sees in ACT!
If objBaseView.Type = 1 Then 'The user is using the Contact View/Screen
(Type 1).
Dim objContactView As act.CAIContactView 'declare an object of type
Contact View
'get the "Active" view/screen the user is using - again!
Set objContactView = objViewsCollection.GetActive
=========================================================
Here is my code i've coded based on this: -
===================================
sing System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
axActEvent1.Register(0);
bool isit = axActEvent1.IsActRunning();
act.CActAppObj objACT = new act.CActAppObj();
act.CAIBaseView objBaseView = new act.CAIBaseView();
act.CAIViews objViewsCollection = new act.CAIViews();
MessageBox.Show(isit.ToString());
}
private void axActEvent1_OnDatabaseOpen(object sender,
AxACTEVENTLib._DActEventEvents_OnDatabaseOpenEvent e)
{
}
private void axActEvent1_OnContactAdd(object sender,
AxACTEVENTLib._DActEventEvents_OnContactAddEvent e)
{
}
}
}
==
Now my code is mostly working. For example the register(0) is returning
a success. And after much tweaking about with the wizard generated code
I have my OnContactAdd event working, so when a new contact is added in
ACT my event fires in my code. So i seem to have a communication of
sort between ACT and my program. The problem I have at the moment is
the functionality I want is based on those three lines I pasted at the
start of this post: -
act.CActAppObj objACT = new act.CActAppObj();
act.CAIBaseView objBaseView = new act.CAIBaseView();
act.CAIViews objViewsCollection = new act.CAIViews();
And lines 2 and 3 seem to be generating this error I've mentioned.
Any ideas would be appreciated.
Thanks,
Gary.
having trouble.
I have three bits of code like so : -
act.CActAppObj objACT = new act.CActAppObj();
act.CAIBaseView objBaseView = new act.CAIBaseView();
act.CAIViews objViewsCollection = new act.CAIViews();
The first part compiles fine. The second and third. Both generate
errors like so: -
System.Runtime.InteropServices.COMException was unhandled
Message="Retrieving the COM class factory for component with CLSID
{0CD44B28-F861-11D0-9B45-006097B00E23} failed due to the following
error: 80040154."
Source="WindowsApplication1"
ErrorCode=-2147221164
StackTrace:
at WindowsApplication1.Form1.Form1_Load(Object sender, EventArgs
e)
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
at System.Windows.Forms.Control.set_Visible(Boolean value)
at
System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32
reason, ApplicationContext context)
at
System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32
reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at WindowsApplication1.Program.Main()
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[]
args)
at System.AppDomain.ExecuteAssembly(String assemblyFile,
Evidence assemblySecurity, String[] args)
at
Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object
state)
at System.Threading.ExecutionContext.Run(ExecutionContext
executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
Am i right in thinking because the first statement compiles OK the
problem isn't to do with the DLL being registered? Sometime ago when I
last looked at this I seem to remember trying to use a utility called
tlbimp to fix it but didn't get very far.
Someone gave me some code sometime ago which is what my code is based
on.
They said that the code would work for VB6.
I am trying to get it working in .net C# here is some of their code
that i'm basing my code on.
=========================================================
Me.ActEvent1.Register 0 'ACT! must be open. This registers this program
with ACT!
'check and see if ACT! is running
If Me.ActEvent1.IsActRunning <> True Then
MsgBox "Open ACT! and start again.", vbCritical, "ACT! is closed"
End
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
'Unregister with ACT! when our program unloads.
Me.ActEvent1.UnRegister
End Sub
'ACT! informs you of this event when a user adds a new Contact
'from the Contact View or Contact List View in ACT!
Private Sub ActEvent1_OnContactAdd(ByVal lpszUniqueID As String)
Dim objACT As New act.CActAppObj 'The ACT application object
Dim objViewsCollection As act.CAIViews 'The collection of all views in
ACT!
Dim objBaseView As act.CAIBaseView 'A generic "base view" in ACT! We
need this to determine
'if the new Contact is being added from the Contact view/screen
'or the Contact List view/screen.
Set objViewsCollection = objACT.Views 'Get all view from ACT!
Set objBaseView = objViewsCollection.GetActive 'Get the active
view/screen from the collection
'This logic determines which view/screen the user is using when adding
the new Contact.
'NOTE: the "Active" view is the currently visible view/screen the user
sees in ACT!
If objBaseView.Type = 1 Then 'The user is using the Contact View/Screen
(Type 1).
Dim objContactView As act.CAIContactView 'declare an object of type
Contact View
'get the "Active" view/screen the user is using - again!
Set objContactView = objViewsCollection.GetActive
=========================================================
Here is my code i've coded based on this: -
===================================
sing System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
axActEvent1.Register(0);
bool isit = axActEvent1.IsActRunning();
act.CActAppObj objACT = new act.CActAppObj();
act.CAIBaseView objBaseView = new act.CAIBaseView();
act.CAIViews objViewsCollection = new act.CAIViews();
MessageBox.Show(isit.ToString());
}
private void axActEvent1_OnDatabaseOpen(object sender,
AxACTEVENTLib._DActEventEvents_OnDatabaseOpenEvent e)
{
}
private void axActEvent1_OnContactAdd(object sender,
AxACTEVENTLib._DActEventEvents_OnContactAddEvent e)
{
}
}
}
==
Now my code is mostly working. For example the register(0) is returning
a success. And after much tweaking about with the wizard generated code
I have my OnContactAdd event working, so when a new contact is added in
ACT my event fires in my code. So i seem to have a communication of
sort between ACT and my program. The problem I have at the moment is
the functionality I want is based on those three lines I pasted at the
start of this post: -
act.CActAppObj objACT = new act.CActAppObj();
act.CAIBaseView objBaseView = new act.CAIBaseView();
act.CAIViews objViewsCollection = new act.CAIViews();
And lines 2 and 3 seem to be generating this error I've mentioned.
Any ideas would be appreciated.
Thanks,
Gary.