System windows forms unsafenativemethods cocreateinstance

CoCreateInstance function (combaseapi.h)

Creates and default-initializes a single object of the class associated with a specified CLSID.

Call CoCreateInstance when you want to create only one object on the local system. To create a single object on a remote system, call the CoCreateInstanceEx function. To create multiple objects based on a single CLSID, call the CoGetClassObject function.

Syntax

Parameters

The CLSID associated with the data and code that will be used to create the object.

If NULL, indicates that the object is not being created as part of an aggregate. If non-NULL, pointer to the aggregate object’s IUnknown interface (the controlling IUnknown).

Context in which the code that manages the newly created object will run. The values are taken from the enumeration CLSCTX.

A reference to the identifier of the interface to be used to communicate with the object.

Address of pointer variable that receives the interface pointer requested in riid. Upon successful return, *ppv contains the requested interface pointer. Upon failure, *ppv contains NULL.

Return value

This function can return the following values.

Return code Description
S_OK An instance of the specified object class was successfully created.
REGDB_E_CLASSNOTREG A specified class is not registered in the registration database. Also can indicate that the type of server you requested in the CLSCTX enumeration is not registered or the values for the server types in the registry are corrupt.
CLASS_E_NOAGGREGATION This class cannot be created as part of an aggregate.
E_NOINTERFACE The specified class does not implement the requested interface, or the controlling IUnknown does not expose the requested interface.
E_POINTER The ppv parameter is NULL.

Remarks

The CoCreateInstance function provides a convenient shortcut by connecting to the class object associated with the specified CLSID, creating a default-initialized instance, and releasing the class object. As such, it encapsulates the following functionality:

It is convenient to use CoCreateInstance when you need to create only a single instance of an object on the local machine. If you are creating an instance on remote computer, call CoCreateInstanceEx. When you are creating multiple instances, it is more efficient to obtain a pointer to the class object’s IClassFactory interface and use its methods as needed. In the latter case, you should use the CoGetClassObject function.

Читайте также:  Как обновить драйвера при помощи windows

In the CLSCTX enumeration, you can specify the type of server used to manage the object. The constants can be CLSCTX_INPROC_SERVER, CLSCTX_INPROC_HANDLER, CLSCTX_LOCAL_SERVER, CLSCTX_REMOTE_SERVER or any combination of these values. The constant CLSCTX_ALL is defined as the combination of all four. For more information about the use of one or a combination of these constants, see CLSCTX.

UWP applications

Although there are no restrictions on which CLSIDs a UWP application can pass to CoCreateInstance, many objects will fail with E_ACCESSDENIED for security reasons, especially if they do not run in-process. Additionally, even if you can successfully create an object, it might fail at a later time due to UWP security constraints, app-model differences, etc. In particular, background tasks should limit the objects they communicate with to avoid hangs or other complications due to connected stand-by.

Попытка открыть пакет служб Integration Services и получить сообщение об ошибке

Я установил Visual Studio 2008 и SQL Server 2008 на свою машину. Когда я пытаюсь открыть существующий файл .dtsx с помощью BIDS, я получаю следующую ошибку. Я знаю, что этот файл не поврежден, потому что я могу удаленно работать на другом компьютере и открывать его там без проблем. Любая помощь или предложения были бы весьма признательны.

Ошибка предотвратила загрузку представления. (Microsoft Visual Studio)

Указанный модуль не может быть найден. (Исключение из HRESULT: 0x8007007E)
(System.Windows.Forms)

Место проведения программы:

в System.Windows.Forms.UnsafeNativeMethods.CoCreateInstance(Guid & clsid, Object punkOuter, Int32 context, Guid & iid)
в System.Windows.Forms.AxHost.CreateWithoutLicense(Guid clsid)
в System.Windows.Forms.AxHost.CreateWithLicense(String license, Guid clsid)
в System.Windows.Forms.AxHost.CreateInstanceCore(Guid clsid)
в System.Windows.Forms.AxHost.CreateInstance()
в System.Windows.Forms.AxHost.GetOcxCreate()
в System.Windows.Forms.AxHost.TransitionUpTo (состояние Int32)
в System.Windows.Forms.AxHost.CreateHandle()
в System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
в System.Windows.Forms.Control.CreateControl()
в Microsoft.DataWarehouse.Design.ComponentDiagram.CreateDdsView(Control parentControl)
в Microsoft.DataTransformationServices.Design.DtsComponentDiagram.CreateDdsView(Control parentControl)
в Microsoft.DataWarehouse.Controls.DdsDiagramHostControl.set_ComponentDiagram (значение ComponentDiagram)
в Microsoft.DataTransformationServices.Design.ControlFlowControl.set_ComponentDiagram (значение ComponentDiagram)
в Microsoft.DataTransformationServices.Design.DtsPackageView.CreateControlFlowEditor(VsStyleToolBar pageViewToolBar)
в Microsoft.DataWarehouse.Design.EditorWindow.EnsureViewIsLoaded (представление EditorView)

Я не устанавливал VS11, но то, что я делал несколько месяцев назад, устанавливал VS2012, и это в конечном итоге вызвало эту проблему. Когда я удалил VS2012, все DLL не удалились, поэтому установка VS2008 попыталась их использовать. Это была проблема, которая была решена. Я удалил папку (C:\Program Files (x86)\Common Files\microsoft shared\MSDesigners8), которая содержала все эти DLL, а затем отремонтировала мою установку VS2008. Протестировано исправление, и оно сработало.

Удаление папки C:\Program Files (x86)\Common Files\microsoft shared\MSDesigners8 и восстановление VS2008 разрешили мою проблему.

FYI, у меня был установлен и unistalled SQL Server 2014 раньше, и все эти DLL файлы все еще существуют и вызвали эту проблему.

System.BadImageFormatException at System.Windows.Forms.UnsafeNativeMethods.CoCreateInstance #54

Comments

metageektrent commented Sep 28, 2011

** Please provide a brief description of what was happening immediately prior to this error **

Читайте также:  Выполнен вход через mac os

[Message]
The operating system cannot run . (Exception from HRESULT: 0x800700B6)

[WinVer]
Microsoft Windows NT 6.1.7600.0

[StackTrace]
System.BadImageFormatException: The operating system cannot run . (Exception from HRESULT: 0x800700B6)
at System.Windows.Forms.UnsafeNativeMethods.CoCreateInstance(Guid& clsid, Object punkOuter, Int32 context, Guid& iid)
at System.Windows.Forms.WebBrowserBase.TransitionFromPassiveToLoaded()
at System.Windows.Forms.WebBrowserBase.TransitionUpTo(AXState state)
at System.Windows.Forms.WebBrowser.get_AxIWebBrowser2()
at System.Windows.Forms.WebBrowser.PerformNavigate2(Object& URL, Object& flags, Object& targetFrameName, Object& postData, Object& headers)
at System.Windows.Forms.WebBrowser.PerformNavigateHelper(String urlString, Boolean newWindow, String targetFrameName, Byte[] postData, String headers)
at System.Windows.Forms.WebBrowser.set_Url(Uri value)
at inSSIDer.UI.Forms.FormMain.InitializeComponent() in MetaScanner\UI\Forms\frmMain.Designer.cs:line 470
at inSSIDer.UI.Forms.FormMain..ctor() in MetaScanner\UI\Forms\frmMain.cs:line 73
at inSSIDer.Program.Main(String[] args) in MetaScanner\Program.cs:line 218

The text was updated successfully, but these errors were encountered:

System windows forms unsafenativemethods cocreateinstance

This forum has migrated to Microsoft Q&A. Visit Microsoft Q&A to post new questions.

Answered by:

Question

I develop a Win application (vs 2005) and install on client machine it work with xp,window 7 32 bit operating system, but when i install my application on window 7 64 bit operating system it gives me following error,

how could i resolve this problem

Thanks in Advances

Answers

There are two questions:

  1. Did you install / register the COM component on the Windows 7 x64 machine?
  2. What the target platform of your application, I think you should set the platform to x86, please do not set it as «Any CPU»?

Please register the COM first and then run to test the application, please refer to the document: http://support.microsoft.com/kb/146219/

Bob Bao [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.

System windows forms unsafenativemethods cocreateinstance

This forum has migrated to Microsoft Q&A. Visit Microsoft Q&A to post new questions.

Answered by:

Question

I converted a vb6 application to vb .net 2008. Everything runs fine, then all of a sudden after creating the setup and installing on my machine, I cannot open my MDI form in design view any more.

I re-installed the office 2003 components, and that fixed it. I uninstall and install the the app again, and the error comes back. Please, it is urgent!

Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))

Answers

Are you using any COM componennts in the project?.From the error msg it seems that some dll is not registered properly.

IF you are using any compoenets try to rgister the dll with

Regsvr32 «path of the dll»

If it solved your problem,Please click «Mark As Answer» on that post and «Mark as Helpful». Happy Programming!

Читайте также:  Linux команды установленные приложения

You are using an OCX in your application you must register it before you can use your application.

As Murugan suggested you can try Regsvr32 to register it but make sure that you are running Command prompt in administrative mode.

In you setup project add your OCX file in system directory (Special folder -> System Folder) and it will be registered automatically.

Please mark those posts as answer which answers your question. Faraz

Ok, I did find the dll:AxInterop.MSComDlg.dll, to register, but it registers with an error which says the entry point could could not be found though loaded.

Please any suggestions would help!

Here is the resolved thread which will help you to resolve the issue here:

If you have any questions, please feel free to tell us.

Neddy Ren [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.

All replies

Are you using any COM componennts in the project?.From the error msg it seems that some dll is not registered properly.

IF you are using any compoenets try to rgister the dll with

Regsvr32 «path of the dll»

If it solved your problem,Please click «Mark As Answer» on that post and «Mark as Helpful». Happy Programming!

You are using an OCX in your application you must register it before you can use your application.

As Murugan suggested you can try Regsvr32 to register it but make sure that you are running Command prompt in administrative mode.

In you setup project add your OCX file in system directory (Special folder -> System Folder) and it will be registered automatically.

Please mark those posts as answer which answers your question. Faraz

Yeah, I am using some components, the challenge is I have so many ocx files and dlls, and there are so many «interop» dll files that it will be a pain to register all. I wish that error could give a pointer to the missing components or something. And talking of puting those files in system/system32 doesn’t really register those files. I stand to be corrected on that. cuz I tried it once and still have to register at it.

Please, I do appreciate your help. Any other suggestions? Mean while, I’m do the registering if that is what it takes.

Оцените статью