I am trying to reach methods and properties of ObjectFrame through vb.net.
But when I declared this as
Dim objOLEObject As ObjectFrame
and then trying to instantiate it as
ObjOLEObject = New ObjectFrame
it shows error like:
"429: Retriveing the COM class factory for component with CLSID {3806e95d-e47c-11-cd-8701-00aa003f0f7} failed due to the following error: 80040154"
To resolve this we re-installed both MS-Office 2003 and VS-2005, but could not get the solution.
Could anyone suggest me how to declare and use this in vb.net?
Thanks.
Make sure the dll has been registered using regsvr32. Verify by looking in the registry for the CLSID.
Make sure all dependant dll's are available.
I believe this is a class not registered error.
Adding to what Josh is saying, have you checked that all the dependency files are present?
This thread might help.
http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/88a6ea68-f476-4231-822f-27fabe59f458/
Related
Scenario:
My company has a legacy (read that as 32 bit) windows form application that will be around for quite some time in the future. This application uses an embedded web browser control that is supplied pages that are contained within the database that it maintains. It was built like this so we could extend/modify as needed. I say this so that I can validate that security is not a concern. Only the application and developers with the correct tools have access to the pages or database. The application is only available inside the office.
There are some processes that I need to accomplish using ActiveX objects that are embedded within the pages/application. One of the biggest and most annoying thing that happens is the ActiveX security warning when I got to create instances of things like “scripting.filesystemobject”. Example:
Set oFSO = CreateObject("Scripting.FileSystemObject")
My solution is to create a DLL that is installed locally on each machine that needs access to the extended functions, have the all the functions (whole DLL ??) marked as safe so that the web browser control does not present the security warning. I have been searching using google and came across very few examples, and all of which are in C# which is not my strongest language.
I’ve had to convert from C to Vb.Net visual basic to get what I have now. When I go to register my DLL, I get the following error message:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319>regasm
Z:\VBNet2017\APIInternal\APIInternal\bin\Debug\APIinternal.dll /tlb
Microsoft .NET Framework Assembly Registration Utility version 4.8.4084.0
for Microsoft .NET Framework version 4.8.4084.0
Copyright (C) Microsoft Corporation. All rights reserved.
Types registered successfully
RegAsm : error RA0000 : Type 'APIInternal.API.Accupay' has an invalid default COM
interface: 'APIInternal.API.Accupay'
UPDATE: Thank you Hans; the error is gone. I've also made some changes in the source code; I changed the ProgID to something that closely resembles where and what this is for. I'm still having issues in creating the object in VB Script.
This is the output from the current version of the code. This is the code, stripped down for clarity:
Option Strict On
Imports System.Runtime.InteropServices
Imports System.IO
Namespace API
Public Interface IAccupay
<DispId(1)>
Function GetFiles(ByVal Folder As String) As List(Of String)
End Interface
<Guid("8B4B5CEF-8B3A-49A1-9053-E909F82D9E73"),
ProgId("AddIn.Accupay"), ClassInterface(ClassInterfaceType.None),
ComDefaultInterface(GetType(IAccupay)), ComVisible(True)>
Public Class Accupay
Implements IAccupay
Private Function GetFiles(Folder As String) As List(Of String) Implements IAccupay.GetFiles
Return Directory.GetFiles(Folder).ToList
End Function
End Class
I have tried just about every combination of ProgID, Name space, Interface name and class name to get this error to go away without any luck. I do know there are other elements that need to be addressed or added, such as error trapping and, if I’m not mistaken, how to actually implement the ObjectSafetyOption which I still don’t know how to do.
I have been using the Guide at the bottom of this article:
Is it possible to mark an ActiveX object as safe so that IE settings need not be changed?, the second answer, but I haven’t had any success.
Please, can someone point me in the right direction, maybe show me what’s wrong with the code that I have and how to physically implement the ObjectSafteyOption that is needed for the web control. Links, additional reading, code examples or comments on how to get this fixed and working would really be appreciated.
Thank you for reading and any help you send my way, Fred
PS: If you need more information, or have a better solution, please don’t hesitate to reply or comment.
UPDATE:
With the code that I have now, I am able to access the DLL in VB.Net visual basic:
Imports System
Imports APIInternal.API
Module Program
Sub Main(args As String())
Dim API As New Accupay
Dim FileList = API.GetFiles("C:\Windows\")
For Each Item As String In FileList
Console.WriteLine(Item)
Next
End Sub
End Module
However, I still can't seem to get the correct calling for a VB Script/html page:
Set Test = CreateObject("Test.Accupay")
Which returns the VB Script error "ActiveX Component can't create object: Test.Accupay or any other iteration of the parts of the name that I tried. I think part of this is that I don't understand how the creation of the project leads to the creation of the object in a com base environment like VB Script.
Fred
The answer to this problem is two fold: You must target the correct platform (X86) AND use the 32 bit version of regasm. Once I realized this was the issue, I was able to create the DLL and use it's functions in the Web Browser control without the active X warning. One example is I can now open the default browser (in this case, NOT IE/EDGE) from a link within the WB Control and another is to get the contents of a folder for further processing within the WB page.
I am using pywin32 to register a COM object. The COM object get registered and it is avaialable in the registry editor at Computer\HKEY_CLASSES_ROOT\CLSID{B7B60366-B784-451F-BD6A-E7E733DB4E63}.
The problem is that the path in InProc32 includes only pythoncom37.dll. The only way can make the object work is to rename the inproc folder, so that it searches for LocalServer by default.
I believe several problems in the behavior of this object are connected to it not being ran as inproc, hence I really want to get it to run as inproc.
Any Ideas why this is the case? What can I do to change it?
I was using an application and it was working perfect. After some months of not using it, I tried to run it and it doesn't work. It shows a message box saying that it cannot instance a COM object.
Do any know how to track errors in COM objects?
You can use ProcessMonitor and try to find the registry key that may be incorrect.
The other option is to use http://www.moduleanalyzer.com, it intercepts CoCreateInstance showing all created COM objects and the return values.
Run Depends tool on COM object DLL to verify it has all the necessary dlls, re-register the COM dll/exe.
Any HRESULTS from debugging/logs? Any changes in apartment models?
You cannot change the apartment type once you've set one. So if the object cannot use one of the models and you try to CoCreate it, it will fail. That's why you never call CoInit from inside DLL main thread.
Good morning.
I have to access the active x dll which is installed on my system from VB.net.
I added as reference and followed all the steps as given in
I have declared
private mycomponent as activexcomponent.libclass
and i gave constructor for this i.e. creating the object for this class in the constructor of the main form as
mycomponet = new activexcomponent.libclass()
Then the following expection is coming when i tried to run the program.
System.InvalidOperationException: An
error occurred creating the form. See
Exception.InnerException for details.
The error is: Creating an instance of
the COM component with CLSID
{D8A27DFF-A4B8-440E-8571-71A37D39403E}
from the IClassFactory failed due to
the following error: 800a0196. --->
System.Runtime.InteropServices.COMException:
Creating an instance of the COM
component with CLSID
{D8A27DFF-A4B8-440E-8571-71A37D39403E}
from the IClassFactory failed due to
the following error: 800a0196.
I have registered the activex dll. I tried my best to figure out the problem but could not succeed in this.
Please can any one help me out?
Thanks a lot.
As far as I know, that's not a standard HRESULT so you should really read the documentation or contact the developers of the ActiveX control to find out from them what it means. However, I did find comments that for some control it meant that it needs to be shown as modal, so you could try making the form modal (show it using ShowDialog) and see if that makes any difference.
I'm well and truly stuck with MS SOAP 3.0, which I'm currently running from VBA Excel in Office 2003. I have used MS SOAP Toolkit 3 to create a proxy class which I am using. If I don't use it, I don't get the error, but then I'd have to write out the entire proxy class by hand and it's massive.
When my program is first run, I get "Class not registered". If I run it again I get "Interface not supported". The error messge is:
run-time error: '-2147467262'
SoapMapper: The SoapMapper for element
callContextIn could not be created
HRESULT=0x80004002: No such interface
supported.
-WSDLOperation:Initialisation of a SoapMapper for operation getSNFormat
HRESULT=0x80004002: No such interfce
supported.
The error occurs when:
Set sc_PartService = New SoapClient30
Help would be greatly appreciated.
Thanks
Just now I deleted "Set", got an error of course, put it back and it ran properly. Once. Not again, and I've been unable to recreate this. Never encountered anything like that before!
HAve you checked if the COM object exists / is registered?