Problem using a COM object

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.
 
C

Clive Dixon

Error code 0x80040154 means that the COM object it is looking for is not
registered. Possibly your 2nd and 3rd objects are in a different COM server
which is not registered.

--
======================
Clive Dixon
Digita Ltd. (www.digita.com)


Gary said:
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.
 
G

Gary

Hmm the CAIBaseView isn't listed in the documentation, yet it comes up
through the intelisense when i type act.

Any idea how I find out the file that this is in that i need to
register?

Thanks,

Gary.

Error code 0x80040154 means that the COM object it is looking for is not
registered. Possibly your 2nd and 3rd objects are in a different COM server
which is not registered.

--
======================
Clive Dixon
Digita Ltd. (www.digita.com)



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 If
Private Sub Form_Unload(Cancel As Integer)
'Unregister with ACT! when our program unloads.
Me.ActEvent1.UnRegister
'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();


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.

Gary.- Hide quoted text -- Show quoted text -
 
G

Gary

P.S. they are both 'interfaces' if that makes any difference.

Hmm the CAIBaseView isn't listed in the documentation, yet it comes up
through the intelisense when i type act.

Any idea how I find out the file that this is in that i need to
register?

Thanks,

Gary.

Error code 0x80040154 means that the COM object it is looking for is not
registered. Possibly your 2nd and 3rd objects are in a different COM server
which is not registered.
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.- Hide quoted text -- Show quoted text -- Hide quoted text -- Show quoted text -
 
J

Jianwei Sun

Gary said:
P.S. they are both 'interfaces' if that makes any difference.


You cannot instantiate interface, you have to instantiate the object
that implements the class.

Those object may reside in a different dll.

Is the first object which is successfully instantiated also interface ?
I doubt it.

Jianwei
 
G

Gary

Hi i think it is, when I hover the mouse over it (it is light turqiose
in the ide) it is prefexied with the word interface.

I still haven't got any further with this, so any input would be
greatly appreciated.

Thanks,

Gary.
 
G

Gary

i'm still stuck with this
Hi i think it is, when I hover the mouse over it (it is light turqiose
in the ide) it is prefexied with the word interface.

I still haven't got any further with this, so any input would be
greatly appreciated.

Thanks,

Gary.
 
G

Gary

Still I can not find a solution. Experts do you have any idea what is
going wrong here.

"Retrieving the COM class factory for component with CLSID
{0CD44B28-F861-11D0-9B45-006097B00E23} failed due to the following
error: 80040154."

The code that is generating the error is: act.CAIBaseView objBaseView =
new act.CAIBaseView();

However the following code works fine: act.CActAppObj objACT = new
act.CActAppObj();

Both: CActAppObj, and CAIBaseView are prefixed with 'interface' when I
hover the mouse over them.

Someone suggested that the file that caibaseview needs might not be
registered properly but I do not know how to check if this is the case,
or to determine which file this should be.

Thanks,

Gary.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top